eolymp
bolt
Try our new interface for solving problems
Problems

Knight route

Knight route

Given a n * n board with the Knight placed in the first row and first column of an empty board. Moving according to the rules of chess knight, visit each square exactly once.

Print the order of each the cell in which they are visited.

Input

The size of the chess board n (n8).

Output

Print the state of the board with knight moves. If the problem has no solution, print "Solution does not exist".

Time limit 1 second
Memory limit 128 MiB
Input example #1
5
Output example #1
 1  6 15 10 21 
14  9 20  5 16 
19  2  7 22 11 
 8 13 24 17  4 
25 18  3 12 23 
Input example #2
2
Output example #2
Solution does not exist