N=int(input()) P=[] times=0 for _ in range(N): P.append(list(map(int,input().split()))[::-1]) times=max(len(P[-1]),times) #print(P) ans=[] for _ in range(times): for item in P: if len(item)>1: ans.append(item.pop(-2)) print(*ans)