Bitmap

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given a rectangular bitmap of size n×mn \times m. Each pixel of the bitmap is either white or black, and at least one pixel is white. The pixel in row ii and column jj is denoted (i,j)(i, j).

The distance between two pixels p1=(i1,j1)p_1 = (i_1, j_1) and p2=(i2,j2)p_2 = (i_2, j_2) is defined as

d(p1,p2)=i1i2+j1j2.d(p_1, p_2) = |i_1 - i_2| + |j_1 - j_2|.

Write a program that, for every pixel, computes the distance to the nearest white pixel.

Input

The first line contains two integers nn and mm separated by a single space (1n1821 \le n \le 182, 1m1821 \le m \le 182).

Each of the following nn lines contains one string of length mm made of the characters 0 and 1, describing one row of the bitmap. In the string that describes row ii of the bitmap, the jj-th character is 1 if and only if the pixel (i,j)(i, j) is white (1in1 \le i \le n, 1jm1 \le j \le m).

Output

Print nn lines. The ii-th line must contain mm integers f(i,1),,f(i,m)f(i, 1), \dots, f(i, m) separated by single spaces, where f(i,j)f(i, j) is the distance from the pixel (i,j)(i, j) to the nearest white pixel.