0 Tree

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

We have a tree V,E\langle V, E \rangle that consists of nn vertices numbered from 11 to nn. Each vertex iVi \in V has weight a_ia\_i. Each bidirectional edge e=u,vEe = \langle u, v \rangle \in E has weight b_eb\_e. Here, a_ia\_i are non-negative integers, and b_eb\_e are integers.

You can perform at most 4n4 n operations. For each operation, select two vertices XX and YY, and a non-negative integer WW. Consider the shortest path from XX to YY (a path is shortest if the number of edges kk in it is minimum possible). Let this path consist of k+1k + 1 vertices (v_0,v_1,v_2,,v_k)(v\_0, v\_1, v\_2, \ldots, v\_k) where v_0=Xv\_0 = X, v_k=Yv\_k = Y, and for 0i<k0 \leq i < k, the edges e_i=v_i,v_i+1Ee\_i = \langle v\_{i}, v\_{i+1} \rangle \in E. The operation changes the weights as follows:

a_Xa_XW;a_Ya_YW;b_e_ib_e_i+(1)iW for 0i<k.a\_X \leftarrow a\_X \bigoplus W\text{;} \quad a\_Y \leftarrow a\_Y \bigoplus W\text{;} \quad b\_{e\_i}\leftarrow b\_{e\_i} + (-1)^i \cdot W \text{ for } 0 \leq i < k\text{.}

Here, \bigoplus denotes the bitwise XOR operation. We can notice that, if X=YX = Y, nothing will change.

You need to decide whether it is possible to make all a_ia\_i and all b_eb\_e equal to 00. If it is possible, find a way to do so.

입력

The first line contains an integer TT (1T2501 \leq T \leq 250), the number of test cases. Then TT test cases follow.

The first line of each test case contains a single integer nn (1n1041 \leq n \leq 10^4), the number of vertices.

The second line contains nn non-negative integers a_ia\_i (0a_i<2300 \leq a\_i < 2^{30}), the weight on each vertex.

Then n1n - 1 lines follow, each of them contains three integers u_ju\_j, v_jv\_j, w_jw\_j (1u_j,v_jn1 \leq u\_j, v\_j \leq n, 109w_j109-10^9 \leq w\_j \leq 10^9), representing an edge between vertices u_ju\_j and v_jv\_j with weight w_jw\_j. It is guaranteed that the given edges form a tree.

It is guaranteed that n105\sum n \leq 10^5.

출력

For each test case, output "YES" on the first line if you can make all a_ia\_i and all b_eb\_{e} equal to 00 with no more than 4n4n operations. Output "NO" otherwise.

If you can make all weights equal to 00, output your solution in the following k+1k + 1 (0k4n0 \leq k \leq 4n) lines as follows.

On the next line, print an integer kk: the number of operations you make.

Then print kk lines, each line containing three integers XX, YY, and WW (1X,Yn1 \leq X, Y \leq n, 0W10140 \leq W \leq 10^{14}), representing one operation.

If there are several possible solutions, print any one of them.