The first line of input contains a single integer $T$ ($1 \le T \le 10^5$), the number of test cases.
The first line of each test case contains a single even integer $n$ ($2 \leq n \leq 5\times10^4$), the number of nodes in the tree.
The second line contains $n$ integers $c_1$, $c_2$, $\dots$, $c_n$ ($1 \leq c_i \leq \frac{n}{2}$), where $c_i$ is the color of the $i^{th}$ node.
It is guaranteed that no more than two nodes will have the same color.
Each of the following $n-1$ lines will contain two integers $u$ and $v$ ($1 \leq u,v \leq n$), representing an edge between the two nodes $u$ and $v$. It is guaranteed that the given graph is a tree.
The total sum of $n$ over all test cases doesn't exceed $5\times10^5$.