N = int(input()) max_n = 0 ans_l = [] for i in range(N): l = list(map(int, input().split())) max_n = max(max_n, l[0]) ans_l.append(l[1:]) for i in range(N): if max_n - len(ans_l[i]) >= 1: ans_l[i] = ans_l[i] + [0 for i in range(max_n - len(ans_l[i]))] # print(ans_l) l_T = list(zip(*ans_l)) # print(l_T) ans = "" for i in range(max_n): for j in range(N): if l_T[i][j] == 0: continue else: ans = ans + str(l_T[i][j]) + " " print(ans)