Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The relative order of processing queries does not matter.
If we know that for some node v, its parent was updated some number of times, then we know that node v was also updated that number of times.
Iterate on nodes from highest to lowest and count the number of times the query was performed on that node and the number of times this node was updated from its parent (direct or indirect). The parity of that number is the answer.