#C9268. Largest Equal Height Rectangle

    ID: 53342 Type: Default 1000ms 256MiB

Largest Equal Height Rectangle

Largest Equal Height Rectangle

You are given a matrix of integers. Your task is to find the area of the largest rectangle in which all cells have the same height. The area of a rectangle is given by \(\text{area} = \text{width} \times \text{height}\), where the rectangle is defined by contiguous cells in the matrix.

For each test case, you will be provided with the dimensions of the matrix and its elements. Your solution should calculate and output the maximum area of a rectangle containing only the same numbers.

inputFormat

The input starts with an integer \(T\), representing the number of test cases. Each test case begins with two integers \(N\) and \(M\) on a single line, denoting the number of rows and columns, respectively. This is followed by \(N\) lines, each containing \(M\) space-separated integers representing the matrix.

outputFormat

For each test case, print a single line with one integer denoting the maximum area of a rectangle where all cells have the same height.

## sample
2
3 3
1 2 1
1 1 1
1 1 1
4 4
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
6

4

</p>