This question requires that the given n positive integers be filled in the "Spiral matrix" in a non-incrementing order ". The so-called "Spiral matrix" refers to filling in the 1st grids in the upper left corner in a clockwise spiral direction starting from the upper left corner. The size of the matrix is m rows and n columns. The conditions are m × n equal to n; m ≥n; and M? N is the minimum value among all possible values.
Input Format:
The input returns a positive integer N in row 1st and n Positive Integers to be filled in row 2nd. All numbers cannot exceed 104. Adjacent numbers are separated by spaces.
Output Format:
Output spiral matrix. N numbers in each row, m rows in total. Adjacent numbers are separated by one space. No extra space is allowed at the end of the line.
Input example:
1237 76 20 98 76 42 53 95 60 81 58 93
Output example:
98 95 9342 37 8153 20 7658 60 76
Pat-Class B-1050 spiral Matrix