The United Nations Regional Development Agency (UNRDA) has a well-defined organizational structure. It employs people, each coming from one of geographically distinct regions of the world. The employees are numbered from to in order of decreasing seniority, with employee number (the Chair) being the most senior. The regions are numbered from to in arbitrary order. Every employee except for the Chair has a single direct supervisor, who is always more senior than the employee they supervise.
We say that an employee is a manager of employee if and only if is 's supervisor, or is a manager of 's supervisor. Thus, for example, the Chair is a manager of any other employee. Clearly, no two employees can be each other's managers.
Recently, the United Nations Bureau of Investigations (UNBI) received complaints that the UNRDA structure favors some regions over others. To investigate this, the UNBI plans to implement a computer system that, given the supervision structure of the UNRDA, can answer queries of the following form: for two regions r_1 and r_2, how many pairs of employees (e_1, e_2) are there such that employee e_1 comes from region r_1, employee e_2 comes from region r_2, and e_1 is a manager of e_2? Each query has two parameters: region numbers r_1 and r_2, and the result is a single integer: the number of different pairs (e_1, e_2) satisfying these conditions.
Write a program that, given the regions of origin for all agency employees and the supervision chain, interactively answers queries in the described form.
The first line contains three integers: the number of employees (1 \le n \le 200\,000), the number of regions (1 \le r \le 25\,000), and the number of queries (1 \le q \le 200\,000), separated by spaces.
The next lines describe the agency employees by decreasing seniority. The -th line describes the employee with number . The first line (for the Chair) contains a single integer H_1 — the Chair's region. Each of the next n-1 lines contains two integers separated by a space: S_k (1 \le S_k < k, 2 \le k \le n) — the supervisor number for employee , and H_k (1 \le H_k \le r, 1 \le k \le n) — the region of employee .
After reading the input, your program must interactively read queries from standard input and write results to standard output. Each of the queries must be answered one at a time: your program must output the result for each query before reading the next query.
Each query appears on a separate line of input and consists of two integers — the region numbers r_1 and r_2, separated by a space.
The response to each query is a single integer on its own line — the number of pairs of employees (e_1, e_2) such that e_1 comes from region r_1, e_2 comes from region r_2, and e_1 is a manager of e_2.
Example 1
The test data will be such that the answer to any query will always be less than 1\,000\,000\,000.