| Codeforces Round 1076 (Div. 3) |
|---|
| Finished |
The Great Grail Tree has stood in the kingdom for $$$315$$$ years. It takes up a lot of space, so King Ila decided to get rid of it as soon as possible. The tree itself is an acyclic, connected, undirected graph with $$$n$$$ vertices, each having its own value $$$a_v$$$. The tree can be removed in the following way:
Each test consists of several test case. The first line contains one integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line contains the number $$$n$$$ ($$$1\le n\le 2\cdot 10^5$$$) — the number of vertices in the Grail Tree.
The second line describes the array $$$a$$$ ($$$1\le a_i\le 10^9$$$) — the values of the vertices in the tree.
Next, there are $$$n - 1$$$ lines, each containing 2 numbers $$$v$$$ and $$$u$$$ ($$$1\le v, u\le n, v\neq u$$$), indicating that vertices $$$v$$$ and $$$u$$$ are connected by an edge in the tree.
It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output "YES" if it is possible to completely remove the Grail Tree. Otherwise, output "NO". If the answer is "YES", output any sequence of removals.
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
531 2 41 22 343 4 2 11 22 33 469 6 5 1 7 41 22 32 43 54 652 1 1 1 22 13 22 45 451 5 3 7 91 22 33 44 5
NOYES2 3 1 4NOYES1 5 2 3 4YES2 4 1 5 3
| Name |
|---|


