from collections import deque N = int(input()) P = [0]*N A = [[None] for _ in range(N)] ans = deque([]) for i in range(N): tmp = list(map(int,input().split())) P[i] = tmp[0] A[i] = tmp[1:] for i in range(max(P)): for j in range(N): try: ans.append(A[j][i]) except IndexError: continue print(*ans)