#P6497. [COCI 2016/2017 #2] Prosječni

[COCI 2016/2017 #2] Prosječni

Description

Slavko wants to fill an n×nn \times n matrix with n2n^2 distinct positive integers such that:

  • The average of the nn numbers in each row is an integer that appears in that row.
  • The average of the nn numbers in each column is an integer that appears in that column.
  • For any element ai,ja_{i,j} in the matrix, 1ai,j1091 \le a_{i,j} \le 10^9.

Please help him find any feasible solution.

Input Format

One line with one integer nn.

Output Format

This problem uses Special Judge.

If there is no solution, output -1.

Otherwise, output nn lines, each containing nn integers, representing any matrix that meets the requirements.

3 
1 2 3
4 5 6
7 8 9 
2 
-1 

Hint

Sample 1 Explanation

The row averages are 2,5,82,5,8, and each is an integer in its corresponding row.

The column averages are 4,5,64,5,6, and each is an integer in its corresponding column.


Constraints

For 100%100\% of the testdata, 1n1001 \le n \le 100.


Notes

Translated from COCI2016-2017 CONTEST #2 T4 Prosječni

Translated by ChatGPT 5