#K65557. Largest Uniform Subgrid

    ID: 32223 Type: Default 1000ms 256MiB

Largest Uniform Subgrid

Largest Uniform Subgrid

You are given an N x N grid of characters. The task is to find the area of the largest rectangular subgrid (contiguous block) in which all the cells contain the same character. In other words, you need to find the maximum area of a subgrid that is uniform.

Note: A rectangle is defined by two pairs of horizontal and vertical boundaries. The subgrid must be contiguous and may consist of any character as long as it is the same across the subgrid. The area is computed as the number of cells, and if a rectangle has width w and height h, the area is $w \times h$.

You are required to read input from stdin and print the result to stdout for each test case.

inputFormat

The first line of input contains an integer T representing the number of test cases. For each test case:

  • The first line contains an integer N, the size of the grid.
  • The next N lines each contain a string of length N representing the rows of the grid.

All input is read from stdin.

outputFormat

For each test case, output a single integer representing the area of the largest rectangular subgrid that contains only a single unique character. Each answer should be printed on a new line to stdout.

## sample
2
4
aaaa
abbb
accc
abbb
3
abc
bca
cab
4

1

</p>