Time Limit: 2 Seconds
Memory Limit: 131072 KB
Let's play an interesting game!
Look at the graph below, the left most one graph is a basic L shape pattern where n is 1. Now you need to use this basic pattern to cover other bigger but similar L shape boards. The graph below shows the covering scheme when n=2 and n=4, where different colors represent different basic patterns you used.
The input consists of multiple test cases.
For each test case, there is exactly one line consists of n. 1 <= n <= 1000
For each test case, if there exists a covering scheme, then output 2*n lines.
For first n lines, output n space delimited integers in each line. For following n lines, output 2*n space delimited integers in each line.
Each integer in the output should represent the id of basic pattern, that is, the grids sharing same pattern id belongs to the same basic pattern in your covering scheme. Another constraint is 1 <= id <= n*n.
If it's impossible to cover the board using the basic pattern, then simply output a line "impossible"(without quotes).