You are given a tree with N nodes with every node being colored. A color is represented by an integer ranging from 1 to 109. Can you find the number of distinct colors available in a subtree rooted at the node s?
The first line contains three space separated integers representing the number of nodes in the tree (N), number of queries to answer (M) and the root of the tree.
In each of the next N-1 lines, there are two space separated integers(a b) representing an edge from node a to Node b and vice-versa.
N lines follow: N+ith line contains the color of the ith node.
M lines follow: Each line containg a single integer s.
Output exactly M lines, each line containing the output of the ith query.
0 <= M <= 105
1 <= N <= 105
1 <= root <= N
1 <= color of the Node <= 109
4 2 1 1 2 2 4 2 3 10 20 20 30 1 2
Query 1-Subtree rooted at 1 is the entire tree and colors used are 10 20 20 30 , so the answer is 3(10,20 and 30)
Query 2-Subtree rooted at 2 contains color 20 20 30, so the answer is 2(20 and 30)