while True:
try:
row,column=map(int,input().split())
except:
break
matrix=[]
flipped_matrix=[]
for i in range(row):
matrix.append([int(x)for x in input().split()])
flipped_matrix = [[matrix[i][j] for i in range(row)] for j in range(column)]
for i in range(column):
print(*flipped_matrix[i])