While debugging a program, Sanggeun noticed that certain square patterns in program memory are closely related to bugs.
Program memory is an R by C matrix consisting only of 0 and 1.
A square killer is a square submatrix larger than one character that stays exactly the same after being rotated by 180 degrees. In other words, for a square killer of size K, every character at (i, j) from the top-left corner is equal to the character at the symmetric position (K-1-i, K-1-j) from the top-left corner.
Given the program memory, find the size of the largest square killer. The size of a square killer is both its number of rows and its number of columns.
The first line contains natural numbers R and C, each at most 300.
Each of the next R lines contains a string of length C. Every character is either 0 or 1, with no spaces between characters.
Print the size of the largest square killer.
If there is no square killer, print -1.