Knight route#10242

Knight route

1 second
128 megabytes
Medium

You are given a chessboard of size n \times n. A knight is placed in the first row and first column (top-left corner) of an empty board. By following the movement rules for a chess knight, you must visit every cell of the board exactly once.

\InputFileThe size of the chessboard (1 \leq n \leq 8).

\OutputFilePrint the state of the board with the knight's moves in the order they are visited. If there is no solution, print "Solution does not exist".

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading