문제링크
import sys import heapq input = sys.stdin.readline n = int(input().rstrip()) q = [] for _ in range(n): row = list(map(int, input().rstrip().split(" "))) for r in row: heapq.heappush(q, r) while(len(q) > n): heapq.heappop(q) print(heapq.heappop(q))