You are given a tree with vertices. A positive integer is written on vertex .
In one move, choose either a connected component of the subgraph induced by the vertices whose current numbers are even, or a connected component of the subgraph induced by the vertices whose current numbers are odd. Replace the number on every vertex of the chosen component with .
You must choose the entire component; choosing only part of it is not allowed.
Immediately after the move, delete every vertex whose number becomes zero, together with all edges incident to it. The remaining graph may be a forest, and subsequent moves are performed on this graph.
Find the minimum number of moves needed to delete all vertices.
Each pair describes an edge of the tree. For , there are no edge lines.
For each test case, output the minimum number of moves needed to delete all vertices.