The first line contains a single integer $T(T\le 100)$ - the number of test cases.
For each test case:
The first line contains a single integer $n(2\le n \le 5\times 10^5)$ - the number of people.
From the second line to the $(n+1)$-th line, each line contains three integers $b_i,e_i,l_i(0\le b_i,e_i \le 10^9,0\le l_i \le 10^4)$. It is guaranteed that $\sum_{i=1}^n b_i=\sum_{i=1}^n e_i\le 10^9$.
The $(n+2)$-th line contains a single integer $q(0\le q \le 5\times 10^5)$.
Then the next $q$ lines, each line contains two integers $x,y(1\le x \le n,0\le y \le 10^4)$, means that $l_x$ is changed to $y$. Please note that the change in $l_x$ has aftereffects.
It is guaranteed that the sum of $n$ and the sum of $q$ do not exceed $2\times 10^6$.