n,m = map(int,input().split()) list1=[] for i in range(n): a=list(map(int,input().split())) list1.append(a) for i in range(m): for j in range(n): print(list1[j][i],end=" ") print()