Problem: You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is `.` if that square is white.

We will repeatedly perform the following operation until all the squares are black:

* Every white square that shares a side with a black square, becomes black.



Find the number of operations that will be performed. The initial grid has at least one black square.

Constraints

* 1 \leq H,W \leq 1000
* A_{ij} is `#` or `.`.
* The given grid has at least one black square.

Input

Input is given from Standard Input in the following format:


H W
A_{11}A_{12}...A_{1W}
:
A_{H1}A_{H2}...A_{HW}


Output

Print the number of operations that will be performed.

Examples

Input

3 3
...
.#.
...


Output

2


Input

6 6
..#..#
......
..#..
......
.#....
....#.


Output

3

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
const int N = 1009;
int n, m, D[N][N];
int gx[] = {-1, 1, 0, 0}, gy[] = {0, 0, -1, 1};
char A[N][N];
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%s", &A[i]);
	memset(D, 63, sizeof(D));
	queue < pair < int , int > > qu;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (A[i][j] == '#')
				D[i][j] = 0, qu.push({i, j});
	int Mx = 0;
	while (qu.size())
	{
		int i = qu.front().first;
		int j = qu.front().second;
		qu.pop();
		for (int h = 0; h < 4; h++)
		{
			int tx = i + gx[h], ty = j + gy[h];
			if (tx >= 0 && ty >= 0 && tx < n && ty < m && D[tx][ty] > D[i][j] + 1)
				D[tx][ty] = D[i][j] + 1, qu.push({tx, ty});
		}
		Mx = max(Mx, D[i][j]);
	}
	printf("%d\n", Mx);
	return 0;
}