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:

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