Codeforces (342E) Xenia and Tree

Hi, can anyone please help me debug this code for Problem E.

link to my code

It has been days and I’ve not been able to find the error.

I used ‘Centroid Decomposition’.

Thanks in Advance!

See if this helps:

https://codeforces.com/contest/342/submission/33313188

I know this approach. I want to know the mistake in my code.