- Time limit: 1.00 s
- Memory limit: 512 MB
Your task is to construct an grid where each square contains an integer between . There are two requirements:
- Each integer appears exactly times in the grid.
- The rows and columns should form distinct sums.
For example, one possible grid is as follows:
Input
The only input line contains an integer .
Output
You should print any grid that fulfils the requirements. If there is no such grid, you should only print "QAQ".
Example 1
Input:
5
Output:
2 3 1 1 1 1 5 5 3 3 2 3 5 2 4 5 4 5 4 1 2 3 4 4 2
Example 2
Input:
2
Output:
QAQ