You are an HR analyst at a large corporation. The company's organizational structure is a tree, with the CEO at the root. Each employee is a node, and a direct report relationship is an edge. Every employee has been tagged with a primary "skill ID," an integer representing their main expertise.
Your task is to answer a series of queries from management. For any given manager u in the company, they want to know the skill diversity of their team. The skill diversity is defined as the number of unique skills present among that manager and all the employees who directly or indirectly report to them (i.e., their entire subtree).
Input Format:
The first line contains an integer N, the number of employees (nodes).
The next N-1 lines each contain two integers u and v, representing a reporting line between employee u and v.
The next line contains N space-separated integers, where the i-th integer is the skill ID for employee i+1.
The next line contains an integer Q, the number of queries.
The next Q lines each contain a single integer u, the manager for whom to calculate skill diversity.
Output Format:
For each query, print a single integer on a new line representing the count of distinct skills in the queried manager's subtree.
Note:
The tree is rooted at node 1.
The subtree of an employee u includes u themselves, their direct reports, their reports' reports, and so on.