#P7776. Count on a Tree II Striking Back

Count on a Tree II Striking Back

Count on a Tree II Striking Back

Problem Description

You are given a tree with nn nodes. The tree nodes are numbered from 11 to nn. The color of the ii-th node is colicol_i. You need to perform the following operations for mm times:

· "1 x y\texttt{1 x y}" (1x,yn1\leq x,y\leq n): Change the color of the xx-th node into yy.

· "2 a b c d\texttt{2 a b c d}" (1a,b,c,dn1\leq a,b,c,d\leq n): Let's denote f(u,v)f(u,v) as the number of different colors occured on the path from uu to vv. You need to answer whether f(a,b)>f(c,d)f(a,b)>f(c,d) is true.

Input

The first line of the input contains a single integer TT (1T41 \leq T \leq 4), the number of test cases. For each case, the first line of the input contains two integers nn and mm (1n5000001 \leq n \leq 500\,000, 1m100001\leq m\leq 10\,000), denoting the number of nodes and the number of operations. The second line of the input contains nn integers col1,col2,,colncol_1,col_2,\dots,col_n (1colin1\leq col_i\leq n), denoting the initial color of each node. Each of the following n1n-1 lines contains two integers uiu_i and viv_i (1ui,vin,uivi1\leq u_i,v_i\leq n,u_i\neq v_i), denoting an bidirectional edge between the uiu_i-th node and the viv_i-th node. Each of the next mm lines describes an operation in formats described in the statement above, except that some parameters are encrypted in order to enforce online processing. Let cntcnt be the number of queries that you answered "Yes\texttt{Yes}" before in this test case. Note that cntcnt should be reset to 00 in each new test case. For each operation, x,y,a,b,cx,y,a,b,c and dd are encrypted. The actual values of x,y,a,b,cx,y,a,b,c and dd are $x\oplus cnt,y\oplus cnt,a\oplus cnt,b\oplus cnt,c\oplus cnt$ and dcntd\oplus cnt. In the expressions above, the symbol "\oplus" denotes the bitwise exclusive-or operation. Also note that the constraints described in the statement above apply to the corresponding parameters only after decryption, the encrypted values are not subject to those constraints. It is guaranteed that f(a,b)2f(c,d)f(a,b)\geq 2f(c,d) or f(c,d)2f(a,b)f(c,d)\geq 2f(a,b) always holds for each query.

Output

For each query, print a single line. If f(a,b)>f(c,d)f(a,b)>f(c,d) is true, print "Yes\texttt{Yes}" else print "No\texttt{No}".

Sample Input

1
8 4
1 2 1 4 1 3 3 2
1 2
2 3
3 4
3 5
1 6
6 7
6 8
2 1 4 3 5
2 7 6 5 9
1 4 9
2 2 4 7 6

Sample Output

Yes
No
Yes

Source

2020 Multi-University Training Contest 2