Guadalajara is famous for its majestic mountains in the north and its well-known coastal town, Villanueva de la Torre. The regal, grand and dignifiedis danx is visiting Hectorungo, and during his visit, he will conduct a survey about the water in the alcarrian towns.
We have $$$2n-1$$$ towns, all associated with a river, organized in a tree structure where town $$$2n-1$$$ is the root.
In each town with index $$$i$$$ $$$(1 \leq i \leq n)$$$, a river originates with color $$$i$$$. Each town with index $$$j$$$ $$$(n+1 \leq j \leq 2n-1)$$$ connects two towns with smaller indices $$$a$$$ and $$$b$$$ $$$(a, b \lt j)$$$, and the rivers from these towns merge at $$$j$$$. The river of town $$$j$$$ will contain all the colors of the rivers from towns $$$a$$$ and $$$b$$$.
Each town has a population of $$$p_i$$$ inhabitants $$$(1 \leq p_i \leq 10^9)$$$.
Dani will ask $$$q$$$ questions. In each question, he will give a number $$$r$$$ followed by $$$r$$$ distinct numbers $$$c_1, c_2, \dots, c_r$$$ $$$(1 \leq c_i \leq n)$$$, where $$$c_i$$$ denotes a color.
Your task is to determine how many inhabitants live in towns whose river contains at least one of the colors given in the query.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^5)$$$, indicating the number of test cases. Each test case is defined as follows:
An integer $$$n$$$ $$$(1 \leq n \leq 10^5)$$$, the number of towns where a river originates.
A list of $$$2n-1$$$ integers $$$p_1, p_2, \dots, p_{2n-1}$$$ $$$(1 \leq p_i \leq 10^9)$$$, where $$$p_i$$$ is the number of inhabitants in town $$$i$$$.
$$$n-1$$$ additional lines, where the $$$j$$$-th line $$$(n+1 \leq j \leq 2n-1)$$$ contains two integers $$$a$$$ and $$$b$$$ $$$(1 \leq a, b \lt j)$$$, representing the indices of the towns whose rivers merge at town $$$j$$$.
A line with an integer $$$q$$$ $$$(1 \leq q \leq 2 \cdot 10^5)$$$, indicating the number of queries.
$$$2q$$$ additional lines, where each line describes a query.
Each query contains on the first line an integer $$$r$$$ $$$(1 \leq r \leq 10^5)$$$. The second line of each query will contain $$$r$$$ distinct integers $$$c_1, c_2, \dots, c_r$$$ $$$(1 \leq c_i \leq n)$$$, representing the river colors to query.
The total sum of $$$r$$$ in all queries across all cases will not exceed $$$2 \cdot 10^5$$$ and the sum of $$$n$$$ across all casses will not exceed $$$1 \cdot 10^5$$$.
For each query, you must tell Dani how many inhabitants live in a town whose river contains at least one of the colors given in the query.
2 4 1 2 3 4 5 6 7 1 2 3 4 5 6 4 1 1 1 4 2 1 2 3 1 3 4 4 31 14 15 92 65 35 89 1 2 3 5 4 6 4 2 1 5 2 2 4 3 2 3 4 2 6 7
13 17 15 26 220 295 310 124