Recently Alex has been learning about “Tree” data structure. While he was learning, a question popped up on his mind, “How many child nodes and descendant nodes (subchilds) can be visited from a specific node given root?”. Child nodes A node directly connected to another node when moving away from the root, an immediate descendant. Descendant nodes A node reachable by repeated proceeding from parent to child. Also known as subchild. Input: The first line contains the number of test cases 1<= T<=10. The next line contains N (2<=N<=10000).The next N-1 line contains X Y (1<=X, Y<=N and X≠Y) Where X is the parent of Y. The next line contains number of Query Q (1<=Q<=100000), next Q lines contains a node number P (1<=P<=N). Note that, we will assume that the node 1 is always root. Output: You should output the Case number followed by the number of child nodes and descendant nodes can be visited from node P. See Output formation to understand clearly.
These pictures describes the given test case.
1 12 1 2 1 3 1 6 2 4 2 5 5 10 5 8 10 11 6 9 6 7 9 12 2 6 2
Case 1: 3 5