#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 nodes. The tree nodes are numbered from to . The color of the -th node is . You need to perform the following operations for times:
· "" (): Change the color of the -th node into .
· "" (): Let's denote as the number of different colors occured on the path from to . You need to answer whether is true.
Input
The first line of the input contains a single integer (), the number of test cases. For each case, the first line of the input contains two integers and (, ), denoting the number of nodes and the number of operations. The second line of the input contains integers (), denoting the initial color of each node. Each of the following lines contains two integers and (), denoting an bidirectional edge between the -th node and the -th node. Each of the next lines describes an operation in formats described in the statement above, except that some parameters are encrypted in order to enforce online processing. Let be the number of queries that you answered "" before in this test case. Note that should be reset to in each new test case. For each operation, and are encrypted. The actual values of and are $x\oplus cnt,y\oplus cnt,a\oplus cnt,b\oplus cnt,c\oplus cnt$ and . In the expressions above, the symbol "" 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 or always holds for each query.
Output
For each query, print a single line. If is true, print "" else print "".
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