INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque def main(): n = int(input()) ans = [] cus = [] for _ in range(n): a = list(map(int,input().split())) a = a[::-1] cus.append(a[:-1]) while True: update = False for i in range(n): if len(cus[i]) > 0: p = cus[i].pop() ans.append(p) update = True if not update: break print(*ans) if __name__ == '__main__': main()