Spiral Display

easy
1. You are given a number n, representing the number of rows.
2. You are given a number m, representing the number of columns.
3. You are given n*m numbers, representing elements of 2d array a.
4. You are required to traverse and print the contents of the 2d array in form of a spiral.
Note - Please check the sample output for details.

Input Format

A number n A number m e11 e12.. e21 e22.. .. n * m number of elements

Output Format

e11 e21 .. en1 en2 en3 .. enm e(n-1)m .. e1m e1(m-1) .. e12 e22 e32 ..

Constraints

1 <= n <= 10^2
1 <= m <= 10^2
-10^9 <= e1, e2, .. n * m elements <= 10^9

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3
5
11
12
13
14
15
21
22
23
24
25
31
32
33
34
35
Output
11
21
31
32
33
34
35
25
15
14
13
12
22
23
24
Previous
The State Of Wakanda - 1
Next
Exit Point Of A Matrix

Related Questions