Matrix of size n × m is given, consisting of only zeros and ones. Find the largest square submatrix that contains on its sides ones only.
First line contains two integers n and m (1 ≤ n, m ≤ 1500). Each of the next n lines contains m digits 0 and 1 space separated. If there is no such squares, print 0.
Print one integer – the size of maximal square that contains on its sides ones only.