You are given a tree with $$$n$$$ nodes. Each node $$$i$$$ has an initial value $$$A_i$$$.
You can perform a special eat operation. In this operation, you select two nodes, $$$u$$$ and $$$v$$$, that are directly connected by an edge. Node $$$u$$$ can eat node $$$v$$$ only if both of the following conditions are met:
When $$$u$$$ eats $$$v$$$, node $$$v$$$ and the edge connecting them are removed from the tree. The value of node $$$u$$$ is then updated by absorbing $$$v$$$'s value: $$$A_u = A_u + A_v$$$.
Your task is to determine if there exists a sequence of eat operations that results in the tree being reduced to a single node. If it is possible, give any possible sequence.
$$$^{\text{∗}}$$$A leaf is a node that has exactly one edge.
Each test contains multiple test cases. The first line contains the number of test cases $$$T$$$ $$$(1 \le T \le 10^4)$$$. The description of the test cases follows.
The first line contains a single integer $$$N$$$ ($$$2 \le n \le 2*10^5$$$).
The second line contains $$$n$$$ space-separated integers $$$A_1, A_2, \dots, A_n$$$ ($$$1 \le A_i \le 10^9$$$), the initial values of the nodes.
The next $$$n-1$$$ lines each contain two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n, u \ne v$$$), describing an edge between node $$$u$$$ and node $$$v$$$ . It is guaranteed that these edges form a tree and that sum of n over all testcases doesn't exceed $$$2*10^5$$$.
If it's possible to reduce the tree to a single node, first print Yes. Then, print the $$$n-1$$$ operations that achieve this. Each operation should be printed on a new line as two space-separated integers u v, where node u eats node v.
If it's impossible, print No.
453 9 1 2 24 54 31 42 356 6 2 8 12 32 12 54 135 6 23 22 127 31 2
No No Yes 2 3 2 1 Yes 1 2
| Название |
|---|


