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

Description

Slavko wants to fill an $n \times n$ matrix with $n^2$ distinct positive integers such that: - The average of the $n$ numbers in each row is an integer that appears in that row. - The average of the $n$ numbers in each column is an integer that appears in that column. - For any element $a_{i,j}$ in the matrix, $1 \le a_{i,j} \le 10^9$. Please help him find any feasible solution.

Input Format

One line with one integer $n$.

Output Format

**This problem uses Special Judge**. If there is no solution, output `-1`. Otherwise, output $n$ lines, each containing $n$ integers, representing any matrix that meets the requirements.

Explanation/Hint

#### Sample 1 Explanation The row averages are $2,5,8$, and each is an integer in its corresponding row. The column averages are $4,5,6$, and each is an integer in its corresponding column. ------------ #### Constraints For $100\%$ of the testdata, $1 \le n \le 100$. ------------ #### Notes **Translated from [COCI2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #2](https://hsin.hr/coci/archive/2016_2017/contest2_tasks.pdf) _T4 Prosječni_**。 Translated by ChatGPT 5