Given an $N \times M$ matrix made up of $0$s and $1$s, write a program that finds the largest square submatrix consisting entirely of $1$s.
The input consists of several test cases. The first line of each test case contains $N$ and $M$ ($1 \le N, M \le 1{,}000$). Each of the next $N$ lines contains $M$ numbers separated by spaces. The input ends with a line containing two zeros.
For each test case, output the side length (width or height) of the largest square. If no such square exists, output $0$.