Amit has been practicing "pattern printing" problems a lot. To test his ability Jitendra gives him a problem.He tells him to print the given matrix in the diagonal fashion.

Note: Direction of the diagonal is from the upper-right corner to lower-left corner.See sample test cases for more clarification.Imagine you are Amit. Write the code to prove your ability!

Input:

First line contain the values of N and M.

Next N lines contain M space separated numbers.

Output:

Print the given matrix in the diagonal fashion as described.

Constraints:

1 ≤ N,M ≤ 100

0 ≤ element of matrix ≤100

SAMPLE INPUT
3 3
1 2 3 
5 6 7
0 1 2

SAMPLE OUTPUT
1 
2 5 
3 6 0 
7 1 
2
N,M=map(int,raw_input().split())
mat=[]
for i in range(N):
	mat.append(map(int,raw_input().split()))
out=[[] for _ in range(N+M-1)]
for i in range(N):
	for j in range(M):
		out[i+j].append(mat[i][j])
for l in out:
	print " ".join(map(str,l))