시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 10 7 4 66.667%

문제

Input is the matrix A of N by N non-negative integers.

A distance between two elements Ai,j and Ap,q is defined as |i − p| + |j − q|.

Your program must replace each zero element in the matrix with the nearest non-zero one. If there are two or more nearest non-zeroes, the zero must be left in place. 

입력

Input file contains the number N followed by N2 integers, representing the matrix rowby-row. 

출력

Output file must contain N2 integers, representing the modified matrix row-by-row. 

제한

  • 1 ≤ N ≤ 200, 0 ≤ Ai ≤ 1000000 

예제 입력 1

3
0 0 0
1 0 2
0 3 0

예제 출력 1

1 0 2
1 0 2
0 3 0