402350: GYM100735 E Restore
Description
Given a matrix A of size N * N. The rows are numbered from 0 to N-1, the columns are numbered from 0 to N-1. In this matrix, the sums of each row, the sums of each column, and the sum of the two diagonals are equal.
For example, a matrix with N = 3:
The sums of each row:
2 + 9 + 4 = 15
7 + 5 + 3 = 15
6 + 1 + 8 = 15
The sums of each column:
2 + 7 + 6 = 15
9 + 5 + 1 = 15
4 + 3 + 8 = 15
The sums of each diagonal:
2 + 5 + 8 = 15
4 + 5 + 6 = 15
As you can notice, all sums are equal to 15.
However, all the numbers in the main diagonal (the main diagonal consists of cells (i, i)) have been removed. Your task is to recover these cells.
InputThe first line contains the dimension of the matrix, n (1 ≤ n ≤ 100).
The following n lines contain n integers each, with removed numbers denoted by 0, and all other numbers - 1012 ≤ Aij ≤ 1012.
OutputThe restored matrix should be outputted in a similar format, with n lines consisting of n integers each.
ExamplesInput3Output
0 9 4
7 0 3
6 1 0
2 9 4
7 5 3
6 1 8