The given figure has titans at coordinates at (3,8) and (8,6) and (11,2). We can see that the maximum undefended rectangle is of area 12 units, therefore, the position shown in the picture has a penalty of 12.

Help Levi to find out how much the penalty will cost the given positions of titans.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains three space-separated integers L, B, and N that are the length of the grid, breadth of the grid, and a number of beast titans, respectively.
The next N lines of each test case contain two space-separated integer numbers X and Y that represent the coordinates of the cell occupied by a titan.
Output format :
For each test case, in a separate line, print a single integer which is the penalty of the given configuration.
Note:
You don’t have to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= L, B <= 3000
0 <= N <= MIN(L,B)
1 <= X <= L
1 <= Y <= B
Time Limit : 1 sec
2
6 6 2
2 5
5 2
4 4 1
1 1
4
9
For the first test case:
The given configuration according to the test case is -

We can see that the maximum undefended rectangle is 4 units therefore the penalty for this case will be 4.
For the second test case:
The given configuration according to the test case is -

Clearly, the maximum undefended rectangle is 9 units therefore the penalty for this case will be 9.
2
15 8 3
3 8
8 6
11 2
3 3 0
12
9
Can you check all the possible rectangles?
The idea is to find the area of all possible rectangles formed by the configuration that is every rectangle formed between any four belts of titan reign(that titan can protect) and tore the maximum area out of all the rectangles.
O(N ^ 2), where N denotes the number of titans in the grid.
We are sorting the arrays of x coordinate and y coordinate and then we are iterating y coordinate array for every consecutive pair of x. Therefore, net time complexity will be O(N * log(N)) + O(N * N) = O(N * N).
O(N), where N denotes the number of titans in the grid.
Since we are creating arrays to store x and y coordinates.