Олимпиадный тренинг

Задача 38222. magic square


A magic square is a table containing the numbers 123…  once, so that the sum of the numbers in each row and in each column is equal. We will tell you about one of the methods for constructing magic squares (it is called Siamese). It is only suitable for building squares with an odd side (3355…) .

Let's put the number 1 in the top cell of the central column. Next, we will move diagonally to the right and up, placing the numbers 234… . If we have gone beyond the table up, then we need to go to the bottom cell of the same column and continue from it. If we went beyond the right border, we need to go to the left cell of the line where we were supposed to get. If we went both up and to the right at the same time, then we need to go to the lower left cell of the square.

If there is already a number in the next cell on our way, then instead of going "right-up"; you need to make a move “down” (again, if we go beyond the boundaries of the square, we need to go to the top cell of the same column). Examples for squares 33 and 55 are shown in the pictures.



Input
The input is one natural odd number N, not exceeding 30 – square size.

Imprint
Print the numbers written in a square. It is not necessary to align the numbers by columns. Please note: it is required to display the magic square obtained by applying the specified method.
Examples
# Input Output
1 3 8 1 6 
3 5 7 
4 9 2 
2 5 17 24 1 8 15 
23 5 7 14 16 
4 6 13 20 22 
10 12 19 21 3 
11 18 25 2 9