The first line of the input contains a single number $T$, the number of test cases.
For each test case, the first line contains two integers $n$, $m$.
Next $n$ lines, each line contains three integers $tuner_i$, $level_i$, and $ATK_i$, describe a monster on the desk. If this monster is a Tuner monster, then $tuner_i=1$, else $tuner_i=0$ for Non-Tuner monster.
Next $m$ lines, each line contains integers $level_j$, $ATK_j$, $r_j$, and following $r_j$ integers are the required material of this Synchro Monster (the integers given are the identifier of the required material).
The input data guarantees that the required material list is available, two Tuner monsters or two Non-Tuner monsters won't be required. If $r_i=2$ the level sum of two required material will be equal to the level of Synchro Monster.
$T\leq 10$, $n,m\leq 300$, $1\leq level_i\leq 12$, $0\leq ATK_i\leq 5000$, $0\leq r_i\leq 2$