Narwhy, an underdog underwater undercover agent of Byteland, is executing a signal jamming operation against enemy intelligence networks. His objective is to introduce inconsistencies into the enemy's surveillance data to disrupt their decryption efforts.
The enemy's current intelligence database contains:
Narwhy's jamming strategy is to make the entire dataset inconsistent—ensuring no assignment of positive values $$$r_1,\dots,r_n$$$ can satisfy all constraints. This would force the enemy into time-consuming signal verification.
If the existing intelligence is already inconsistent, no action is needed. Otherwise, Narwhy can inject some of the given $$$d$$$ range suppression signals into the network. The $$$i$$$-th such signal imposes an upper bound $$$w_i$$$ on submarine $$$u_i$$$'s range, but each injection carries an operational cost $$$p_i$$$.
Since Narwhy's main expertise is actually in narwhal tusk operations, he needs your help! Determine the minimum total cost to jam the intelligence system by selecting suppression signals to create an unsatisfiable constraint set.
The first line contains an integer $$$T~(1 \le T \le 500)$$$, representing the number of test cases.
For each test case:
It is guaranteed that for all test cases, $$$\sum n\le 4\times 10^5,\sum a\le 4\times 10^5,\sum b\le 4\times 10^5,\sum c\le 4\times 10^5$$$.
For each test case, output a single integer:
32 0 0 0 11 11 12 2 1004 3 0 3 01 14 41 42 31 21 32 31 2 11 3 12 3 13 1 1 1 21 11 23 31 32 3 21 2 13 1 52 1 7
-1 0 5
| Name |
|---|


