n = int(input()) l = [list(map(int, input().split())) for _ in range(n)] p = max([l[i][0] for i in range(n)]) for i in range(n): l[i]=l[i][1:]+[0]*(p-l[i][0]) l = [i for i in sum(zip(*l),()) if i>0] print(*l)