N=int(input()) P=[[] for i in range(N)] na=0 for i in range(N): buf=list(map(int,input().split())) P[i]=buf[1:] na=max(buf[0],na) ans=[] for i in range(na): for j in range(N): try: ans.append(P[j][i]) except: continue print(" ".join(map(str,ans)))