
This time Ninja is doing research on a matrix of size ‘N’ X ‘M’ initialised with ‘0’. He performs ‘Q’ operations where each operation is denoted by two integers [ a, b ] and he increments the value of the element present at [x, y] in the matrix such that 1 <= x <= a and 1 <= y <= b.
Ninja is busy doing some other work so he needs your help to know the occurrence of the maximum number in the matrix after all operations.
For Example: If one operations is [2, 2] then

Note:
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.
Output Format :
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.
Note:
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
2
3 3 2
2 2
3 3
4 4 3
1 3
3 1
2 2
4
1
Test Case 1: we can see in the image below how we get four occurrence of 2.
Test Case 2: we can see in the image below how we get one occurrence of 3.

2
4 4 4
1 1
2 2
3 3
4 4
3 4 3
1 4
2 2
3 3
1
2
Think the brute force way.
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:
O(Q * N * M), where ‘N’ and ‘M’ are the number of rows and columns and ‘Q’ represents the number of operations.
In the worst case, we need to update the whole matrix in each operation.
O(N * M), where ‘N’ and ‘M’ are the number of rows and columns.
To store the matrix, we need O(N * M) space.