시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB276520.000%

문제

Construct a square matrix with $n$ rows and $n$ columns consisting of nonnegative integers from $0$ to $10^{18}$ such that its determinant is equal to $1$ and there are exactly $a_i$ odd numbers in the $i$-th row for each $i$ from $1$ to $n$, or report that there is no such matrix.

입력

The first line contains a single integer $n$ ($2 \le n \le 50$).

Each of the next $n$ lines contains a single integer $a_i$ ($1 \leq a_i \leq n$).

출력

If there is no matrix that meets the requirements, output -1.

Otherwise, output $n$ lines with $n$ numbers $m_{i,j}$ in each ($0 \leq m_{i,j} \leq 10^{18}$): the elements of the constructed matrix. If there are multiple solutions, print any one of them.

예제 입력 1

2
1
1

예제 출력 1

1 0
0 1

예제 입력 2

2
2
1

예제 출력 2

1 1
1 2

예제 입력 3

4
3
3
3
3

예제 출력 3

1 0 1 1
1 1 1 2
1 1 2 3
0 1 1 3

예제 입력 4

3
2
2
2

예제 출력 4

-1

예제 입력 5

3
3
1
3

예제 출력 5

-1