N = int(input()) L = [[int(l) for l in input().split()] for _ in range(N)] ans = [] p = 0 for i in range(N): p = max(p, L[i][0]) L[i].pop(0) for _ in range(p): for j in range(N): if len(L[j]) == 0: continue ans.append(str(L[j][0])) L[j].pop(0) print(" ".join(ans))