1#The program defines the square matrix 90 degrees clockwise direction.
2m,n = map(int,input().split())
3#m,n are the number of rows and columns.
4#m = int(input('rows'))
5l = []
6for i in range(m):
7 x = list(map(int,input().split())) #for taking the rows a time and split it append to an empty list
8 l.append()
9for i in range(m):
10 for j in range(m-1,-1,-1):
11 print(l[j][i],end=' ')
12 print(end='\n')
13