COCI '16 Contest 2 #4 Prosječni
View as PDFSlavko is bored, so he's filling out an  table with positive integers.
He's particularly happy if he manages to fill out the table so that the following conditions are met:
- The average of the numbers in each row is an integer that is located in the same row.
 - The average of the numbers in each column is an integer that is located in the same column.
 - All numbers in the table are different.
 
Help Slavko find a table that will make him happy.
Input Specification
The first line of input contains the integer  
.
Output Specification
Output  lines, in each line output 
 integers separated by space. Let the 
 number in the 
 line correspond to the value that Slavko will write down in the 
 row and 
 column of the table.
All numbers must be greater than  and smaller than 
.
If there are multiple solutions, output any.
If there is no solution, output -1.
Sample Input 1
3
Sample Output 1
1 2 3
4 5 6
7 8 9
Explanation for Sample Output 1
The averages of individual rows are, respectively: , 
, 
.
The averages of individual columns are, respectively: , 
, 
.
Since the average of each row is located in the corresponding row and the average of each column is located in the corresponding column, the output table will make Slavko happy.
Sample Input 2
2
Sample Output 2
-1
Comments