Balance

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

We say that a matrix AA of size N×NN \times N is balanced if A\[i]\[j]+A\[i+1]\[j+1]=A\[i+1]\[j]+A\[i]\[j+1]A\[i]\[j] + A\[i + 1]\[j + 1] = A\[i + 1]\[j] + A\[i]\[j + 1] for all 1i,jN11 \le i, j \le N - 1.

You are given a matrix AA of size N×NN \times N. Your task is to output another matrix BB of equal size such that BB is balanced and B\[i]\[j]A\[i]\[j]B\[i]\[j] \ge A\[i]\[j] for all 1i,jN1 \le i, j \le N. Furthermore, your BB must have the minimum possible sum of entry values.

입력

The first line of input contains an integer NN, the number of rows and columns of the matrix (1N501 \le N \le 50).

Each of the following NN lines contains NN integers. Together they describe the matrix AA. It is guaranteed that 0A\[i]\[j]35,0000 \le A\[i]\[j] \le 35\\,000 for all 1i,jN1 \le i, j \le N.

출력

On the first line, print the sum of the values of the balanced matrix BB you found. On the next NN lines, print the balanced matrix in the same format as given in the input.

Any output matrix that meets the constraints described in the statement will be accepted. The values of the output matrix are not constrained in any way (specifically, they may exceed the value 35,00035\\,000).