Tree and Queries- Editorial

**Problem Link : **
[Contest][1]
[Practice][2]

**Difficulty : ** Easy-medium

**Pre-requisites : ** Graphs, pre-order traversal, segment trees.

**Solution : **
The solution can be found at this Google Doc.
[Solution][3]

**Setter’s solution : **


[4]


  [1]: http://www.codechef.com/WPC1401/problems/IITK1P05
  [2]: http://www.codechef.com/problems/IITK1P05
  [3]: https://drive.google.com/file/d/0BxD24wnAfwNFOFItcW5BVmhsNW5veGxQWXpIMnNiZXVJNEYw/view?usp=sharing
  [4]: http://www.codechef.com/viewsolution/4942852