Progressions

Ailin is learning algorithms on matrices, and now she have an array of integers and she wonders what is the maximum submatrix that meets the following property: ai,j = ai−1,j +1 (0<i<p, 0≤j<q) ai,j = ai,j−1+1 (0≤i<p, 0<j<q) Where p, q are the dimensions of the submatrix (1 ≤ p ≤ n, 1 ≤ q ≤ m) and n, m are the dimensions of the matrix (1 ≤ n, m ≤ 1000). A submatrix is larger than another if the number of cells of the first is greater than the number of cells in the second. Input Input contains several test cases. Each test case begins with two integers n and m (1 ≤ n, m ≤ 1000), the number of rows and the number of columns of the matrix. The following n lines contain m numbers each, these are the values of the matrix ai,j (1 ≤ ai,j ≤ 1000). Output For each test case, you have to print in one line the number of elements of the maximum submatrix which meets the above described property. Sample Input 47 3456789 5 4 2 7 8 9 10 6 3 1 8 9 11 11 7 4 2 9 11 10 12 22 44 44 Sample Output 8 1