N=int(input()) P=[[] for i in range(N)] na=0 for _ in range(N): buf=[int(i) for i in input().split()] P[i]=buf[1:] na=max(buf[0],na) for i in range(na): for j in range(N): try: print(P[j][i],end=' ') except: continue print()