Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Consider iterating over the first edge to remove, and then doing some precalculations on the 2 resulting connected components.
Will calculating the XOR of each subtree help?