Problem: You are given a tree of vertices numbered from to . Initially, all vertices are colored white or black.
You are asked to perform queries:
- "u" — toggle the color of vertex (if it was white, change it to black and vice versa).
After each query, you should answer whether all the black vertices form a chain. That is, there exist two black vertices such that the simple path between them passes through all the black vertices and only the black vertices. Specifically, if there is only one black vertex, they form a chain. If there are no black vertices, they do not form a chain.
Input Format: Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains two integers and ().
The second line of each test case contains integers () — the initial color of the vertices. denotes the color of vertex where denotes the color white, and denotes the color black.
Then lines follow, each line contains two integers and (), indicating an edge between vertices and . It is guaranteed that these edges form a tree.
The following lines each contain an integer (), indicating the color of vertex needs to be toggled.
It is guaranteed that the sum of and over all test cases respectively does not exceed .
Output Format: For each query, output "Yes" if the black vertices form a chain, and output "No" otherwise.
You can output "Yes" and "No" in any case (for example, strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive response).
Note: In the second test case, the color of the vertices are as follows:
The initial tree:
The first query toggles the color of vertex :
The second query toggles the color of vertex :
The third query toggles the color of vertex :
The fourth query toggles the color of vertex :