Limits 1s, 512 MB

Recently Alex has been learning about the tree data structure. And, he has been struggling to write a program to determine the number of child nodes and descendant nodes (subchilds) that can be visited from a specific node given root.

Can you help him write a program that does that?

Input

The first line contains $T$ ($1 \le T \le 10$), the number of test cases. The next line contains $N$ ($2 \le N \le 10000$). The next $N-1$ line contains $X$and $Y$ ($1 \le X, Y \le N$ and $X≠Y$) Where $X$ is the parent of $Y$. The next line contains the number of queries $Q$ ($1 \le Q \le 100000$). The next $Q$ lines contain a node number $P$ ($1 \le P \le 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.

Sample

InputOutput
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


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.

Submit

Login to submit.

Statistics

95% Solution Ratio
wajiulEarliest, Mar '20
Liad_HossainFastest, 0.0s
RMN_30654Lightest, 918 kB
hanter32Shortest, 656B
Toph uses cookies. By continuing you agree to our Cookie Policy.