You are given an N×N matrix A of non-negative integers.
The distance between two elements Ai,j and Ap,q is defined as ∣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.
The first line contains the integer N. It is followed by N2 integers giving the matrix in row-major order.
Print the resulting matrix. Output each row on its own line, with the N integers of a row separated by single spaces.