Help in Tree problem.
https://www.codechef.com/problems/TREES
How to solve this one?detailed approach please.