

Indexing of matrix starts from [1, 1] i.e. first element of matrix is [1, 1].
The first line of input contains an integer 'T' representing the number of test cases.
The first line of each test case contains three integers ‘N’, ‘M’ and ‘Q’ denoting the number of rows, number of columns of the matrix and number of operations respectively.
The next ‘Q’ lines contain two space-separated integers denoting the operation.
For each test case, return a single integer denoting the number of occurrences of the maximum number.
The output for each test case is printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 200
1 <= M <= 200
1 <= Q <= 200
1 <= A <= N
1 <= B <= M
Time limit: 1 second
The idea here is to do exactly the same as written in the question. We will apply brute force and increase each element in the matrix and after all operations, we iterate on the matrix once more to find the occurrence of the maximum number.
Algorithm:
As we can observe that all operations are performed on a submatrix starting from (0, 0) and the maximum element will be only those who are present in all the operations.
So we need to find the intersection of all operations which we can do by finding the minimum row in all operations and minimum columns of each operation.
Algorithm: