
Given a 2D matrix, print all elements of the given matrix in diagonal order.
See the sample input.
Line 1 : Number of rows R and cols C in the matrix
Line 2 : RXC elements of the matrix separated by space
Output Format :
Print the diagonals
1 <= R <= 10^3
1 <= C <= 10^3
3 4
8 3 0 7
0 3 1 8
3 9 8 7
8
0 3
3 3 0
9 1 7
8 8
7