‘Tell me about the bonus level—where a space probe walks over the surface of a planet and collects resources.’
‘I needed to decompose the spherical surface into cells. For this, I inscribed a cube in the sphere,
and each face of the cube had an n × n square grid on it.
Then I projected the grid from the surface of the cube to the surface of the sphere so that the projection center
was the common center of the sphere and the cube.
This produced a grid of 6n2 cells on the surface of the sphere.
Each cell is a spherical quadrangle. The automatic probe can walk over the cells.
The probe always leaves a cell through a side opposite to the side through which it entered this cell.
It is not allowed to move through the grid nodes.’
‘Now I need to distribute resources among the cells. This problem is more difficult.
Each cell should contain some integer amount of resources in the range from 1 to 6n2,
and these amounts should be different for any two cells.
To decrease the luck factor, I want to distribute the resources so that the amount of resources
collected by the probe in one complete cycle over the sphere should be independent of the cell
where the probe starts the cycle and of the direction of motion.
A complete cycle always contains exactly 4n cells. The probe walks over them and returns
to the cell from which it started the journey.’
‘Do you know how to solve this problem?’
‘Yes, but it’s not easy. You can try and solve it yourself.’
The only line contains the integer n (1 ≤ n ≤ 100).
Output 6n2 different integers in the range from 1 to 6n2, which correspond
to the amount of resources in each cell of the sphere. The output should have the form of
a T-shaped unfolded cube with the integers written on it. Use the format given in the example.
3 15 19 4 12 24 18 5
1 7 9 23 21 17 6 16
Problem Author: Denis Dublennykh
Problem Source: Ural Sport Programming Championship 2013