Recently, Alice and Bob are working on a resource-sharing computation model. In this model, there are two processing units, and a memory space which could be represented as unlimited linear grids $ \ldots, A_{-3}, A_{-2}, A_{-1}, A_0, A_1, A_2, A_3, \ldots$. Each processing units has a pointer to mark exactly one grid in the memory. In each clock turn, the pointer would stay at the current grid, move the pointer one grid forward, or move the pointer one grid backward. In their work, Alice and Bob would submit their codes, and their programs would start at the same time. Initially, both pointers would be located at a random grid, and move according to a set of instructions. If both pointers are at the same grid at the same time, the confliction counter would plus one and record it(If their initial grids are the same, the counter would still record it). Now it is your job to find the maximum conflictions the counter could record.
Input
The first line is the number of test cases.
For each test case, the first is an integer $N_{Alice} (N_{Alice} \leq 100000)$, donating the length of the instructions of Alice.
The next $N_{Alice}$ lines describe Alice`s instructions. Each line consists of two integer $c, t$. $c$ could be $-1, 0, 1$, donating moving forward, staying, and moving backward respectively. $t$ is a non-negative integer donating that the instruction $c$ would be executed $t$ times, in the next $t$ clock turns.
The next line is an integer $N_{Bob} (N_{Bob} \leq 100000)$, donating the length of the instructions of Bob.
The next $N_{Bob}$ lines describe Bob`s instructions. Each line consists of two integer $c, t$. $c$ could be $-1, 0, 1$, donating moving forward, staying, and moving backward respectively. $t$ is a non-negative integer donating that the instruction $c$ would be executed $t$ times, in the next $t$ clock turns.
Suppose $L_{Alice}$ equals the sum of all $t$ in Alice's program, and $L_{Bob}$ equals the sum of all $t$ in Bob's program.
It is guaranteed $L_{Alice} = L_{Bob}$ and $L_{Alice}, L_{Bob} \leq 10^{18}$.
Output
For each test case, output a line containing the maximum conflictions.