#K59572. Largest Uniform Rectangular Area in a Grid

    ID: 30894 Type: Default 1000ms 256MiB

Largest Uniform Rectangular Area in a Grid

Largest Uniform Rectangular Area in a Grid

Given a grid of tiles where each tile is represented by an uppercase English letter indicating its color, your task is to find the area of the largest rectangular subgrid in which all tiles have the same color.

For a subgrid defined by its top-left corner at (rstart, cstart) and bottom-right corner at (rend, cend), the area is computed as:

\( area = (r_{end} - r_{start} + 1) \times (c_{end} - c_{start} + 1) \)

You must evaluate each rectangular region and determine the largest area that meets the criteria of having a uniform color throughout.

inputFormat

The input consists of multiple datasets. Each dataset begins with a line containing two integers R and C (the number of rows and columns). Following this, there are R lines each containing a string of length C representing the grid rows. The grid is composed of uppercase English letters.

The input terminates with a line containing "0 0" which should not be processed.

outputFormat

For each dataset, output a single integer on a separate line: the area of the largest rectangular subgrid where all tiles are of the same color.

## sample
3 3
AAA
AAA
AAA
0 0
9

</p>