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())

matrix = []
for x in range(n):
    matrix.append(map(int,raw_input().split()))
maxsum = n + m - 2
for sums in range(maxsum+1):
    for i in range(n):
        for j in range(m):
            if i + j - sums == 0:
                print matrix[i][j],
    print