Maximal square#7837

Maximal square

1 second
122.174 megabytes
Hard

Matrix of size n \times m is given, consisting of only zeros and ones. Find the largest square submatrix that contains on its sides ones only.

Input

First line contains two integers and ( ≤ , ≤ ). Each of the next lines contains digits and space separated.

Output

Print one integer – the size of maximal square that contains on its sides ones only. If there are no such squares, print .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading