Ayush is tasked with painting a few electric poles in BIT Mesra. The poles to be painted are marked in an NxM grid, repesenting the map of BIT. Ayush needs your help in finding the minimum cost required to paint all the required poles.
The strange thing about the grid is, there is no cost involved in moving from the one row to the other, whereas moving to an adjacent coloum has a unit cost associated with it. If Ayush is free to start from any cell in the grid, help him to find the minimum cost to paint all the poles.
Input Format
First line contains T testcases.
Each Testcase contains three integers N, M and Q, where N and M are the dimentions of the NxM grid with top-left cell denoted by (0,0).
The next Q lines contain two integers X and Y, the co-ordinates of a electric pole to be painted.
Output Format
A single line for each test case, denoting the minimum cost required to paint the poles.
Constraints
1 <= T <= 100
1 <= N, M <= 10^5
0 <= Q <= 1000
0 <= X < N
0 <= Y < M