Given a grid of size NxM, a man wants to reach the exit point, which is located at the top-right cell of the matrix. From the current cell the man can either move to the upper cell or the right cell.
Some of the cells contain hole and it is not possible to move to those cells.
Now, it can be clearly observed that starting from a cell, it is not always possible to reach the exit, such starting cells are called BAD CELLS.
You need to count such bad cells in the matrix.
Note: The matrix is numbered as shown in the figure.
INPUT
First line contains number of test cases T.
First line of each test case contains three integers N,M and W, indicating number of rows, columns and horizontal sequence of holes, respectively.
Each of the next W lines contains four integers X1,Y1,X2,Y2, where (X1,Y1) and (X2,Y2) are the coordinates of the start and end of the sequence of holes.
OUTPUT
For each test case output a single integer indicating the number of BAD CELLS in the matrix.
CONSTRAINTS
1<=T<=20
1<=N,M<=10^6
1<=W<=1000
0<=X1<=X2 <M
0<=Y1=Y2 <N
The yellow boxes indicates the boxes from which the man won't be able to reach the exit. So, there are 8 such boxes.