from collections import deque n = int(input()) customers = [] lmax = 0 for i in range(n): line = input().split() if int(line[0]) > lmax: lmax = int(line[0]) customers.append(line[1:]) for x in customers: if int(x[0]) > lmax: lmax = int(x[0]) dic = {} for x in range(n): for c in range(len(customers[x])): dic[(x,c)] = customers[x][c] re = "" for x in range(lmax): for y in range(n): if dic.get((x,y)): re += dic.get((x,y)) re += " " print(re[:-1])