n = int(input()) A = [0]*n for i in range(n): temp = list(map(int, input().split())) if len(temp) == 1: A[i] = [] else: a = temp[1:] a.reverse() A[i] = a ans = [] while True: cnt = 0 for i in range(n): if A[i]: ans.append(A[i].pop()) else: cnt += 1 if cnt == n: break print(*ans)