Nearest number - 2

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given an N×NN \times N matrix AA of non-negative integers.

The distance between two elements Ai,jA_{i,j} and Ap,qA_{p,q} is defined as ip+jq|i - p| + |j - q|.

Replace every zero element of the matrix with the value of the nearest non-zero element. If two or more non-zero elements are tied for the minimum distance, leave that zero unchanged.

Input

The first line contains the integer NN. It is followed by N2N^2 integers giving the matrix in row-major order.

Output

Print the resulting matrix. Output each row on its own line, with the NN integers of a row separated by single spaces.

Constraints

  • 1N2001 \le N \le 200, 0Ai,j10000000 \le A_{i,j} \le 1000000