Given a matrix A of M rows and N columns, write a program to print the elements of A in a sequence that looks like an anti-clockwise spiral form of A.
Input:
The first line contains two space-separated integers M and N.
Each of the following M lines contains N space-separated integers.
Output:
Print space-separated integers representing the anti-clockwise spiral form of A.
Explanation:
For M = 4, N = 4
matrix A:
10 11 12 13
21 22 23 14
20 25 24 15
19 18 17 16
Output:
10 21 20 19 18 17 16 15 14 13 12 11 22 25 24 23
Constraints:
1 <= M, N <= 200
1 <= each element of matrix <= 10^9
Test cases:
Input:
3 3
1 2 3
4 5 6
7 8 9
Output:
1 4 7 8 9 6 3 2 5
Input:
4 4
66 9 34 3
46 64 44 94
8 100 93 12
11 71 52 25
Output:
66 46 8 11 71 52 25 12 94 3 34 9 64 100 93 44