12884 - Patruto and Spongebob run away   

Description

After finishing dinner in SAO, it's time to have the bill. But Spongebob only has bubble-money and Patrick only has rock-money.

Of course they can't pay in neither bubble-money nor in rock-money. So the cashier is so mad that he calls the police to catch them. Spongebob and Patrick feel scared and they run away immediately(please don’t imitate them). To prevent from being caught, Patrick decide to cosplay a ninja.

Assuredly Patrick needs to move like a ninja, too. Formally we call "moving like a ninja" is that the footprint he left will form a swirl like the design on the forehead which Patrick put on. And you have to help Patrick to move like a ninja.

To simplify the problem, we consider Patrick is on a 2n x 2n grid. And he is at the upper-left cell (1,1) in the begining. When he starts to move, he will go right continuously until the next cell he will move to is out of bounds or has been visited before. Then he will go down with the same pattern(stops when the next cell is out of bounds or has been visited). Similarly he goes left and goes up with the same pattern. And continue to keep going right, going down, going left, going up, going right, going down… until he can’t move anymore.

What you have to do is to offer a map. And there must be a 2n 2n grid on the map and all the cells in the grid are noted the order Patrick should visit. In this way Patrick can move like a ninja by following your map(don’t worry about Patrick’s counting ability).

The following image shows the example of  n = 3(so the grid is 6 x 6).

 

Subtask

- for testcase 1:  n = 1

- for testcase 2:  n = 2

- for testcase 3:  n = 3

- for testcase 4:  n = 4

- for testcase 5~10: no additional restriction

Input

The first line contains one integer n (1 ≤ n ≤ 250) – the size of the grid which Patrick moves on.

Output

Output a 2n x 2n grid which is the map Patrick will follow.

Please reference the format of sample output and do not output space at the end of any line.

Remember to print a newline('\n') at the end of the last line.

Sample Input  Download

Sample Output  Download

Tags




Discuss