N = int(input()) PA = [list(map(int, input().split())) for _ in range(N)] P = 0 for i in range(N): P = max(P, PA[i][0]) p = 0 ans = [] for p in range(1, P+1): for i in range(N): if p<=PA[i][0]: ans.append(PA[i][p]) print(*ans)