The first line contains an integer $T$, denoting the number of test cases.
For each test case, the input format is as follows:
| $n$ | | | | |
|-----------|-----------|------------|----------|--------|
| $c_1$ | $c_2$ | $c_3$ | $\ldots$ | $c_n$ |
| $wn_1$ | $wn_2$ | $wn_3$ | $\ldots$ | $wn_n$ |
| $u_1$ | $v_1$ | $we_1$ | | |
| $u_2$ | $v_2$ | $we_2$ | | |
| $\vdots$ | $\vdots$ | $\vdots$ | | |
| $u_{n-1}$ | $v_{n-1}$ | $we_{n-1}$ | | |
It is guaranteed that:
- $1\le T \le 10^3$
- $1\le n \le 10^5$, $\sum n\le 10^6$
- $1\le c_i, wn_i, we_i \le 10^6$