#P15822. [JOI Open 2013] Synchronization

[JOI Open 2013] Synchronization

Description

The JOI Co., Ltd. has NN servers in total around the world. Each server contains an important piece of information. Different servers contain different pieces of information. The JOI Co., Ltd. is now building digital lines between the servers so that the pieces of information will be shared with the servers. When a line is built between two servers, pieces of information can be exchanged between them. It is possible to exchange pieces of information from one server to another server which is reachable through the lines which are already built.

Each server has a high-performance synchronization system. When two servers can exchange pieces of information each other and they contain different pieces of information, they automatically synchronize the pieces of information. After a synchronization between the server A and the server B, both of the servers A and B will contain all the pieces of information which are contained in at least one of the servers A and B before the synchronization.

In order to reduce the cost, only N1N - 1 lines can be built. After the N1N - 1 lines are built, there will be a unique route to exchange pieces of information from one server to another server without passing through the same server more than once.

In the beginning (at time 0), no lines are built. Sometimes, lines are built in a harsh condition (e.g. in a desert, in the bottom of sea). Some of the lines become unavailable at some point. Once a line becomes unavailable, it is not possible to use it until it is rebuilt.

It is known that, at time jj (1jM1 \le j \le M), the state of exactly one line is changed.

We need to know the number of different pieces of information contained in some of the servers at time M+1M + 1.

Task

Write a program which, given information of the lines to be built and the state of the lines, determine the number of different pieces of information contained in some of the servers.

Input Format

Read the following data from the standard input.

  • The first line of input contains three space separated integers N,M,QN, M, Q. This means the number of the servers is NN, a list of MM changes of the state of the lines is given, and we need to know the number of different pieces of information contained in QQ servers.
  • The ii-th line (1iN11 \le i \le N - 1) of the following N1N - 1 lines contains space separated integers Xi,YiX_i, Y_i. This means the line ii, when it is built, connects the server XiX_i and the server YiY_i.
  • The jj-th line (1jM1 \le j \le M) of the following MM lines contains an integer DjD_j. This means the state of the line DjD_j is changed at time jj. Namely, if the line DjD_j is unavailable just before time jj, this line is built at time jj. If the line DjD_j is available just before time jj, this line becomes unavailable at time jj. When the state is changed at time jj, all the synchronization processes will be finished before time j+1j + 1.
  • The kk-th line (1kQ1 \le k \le Q) of the following QQ lines contains an integer CkC_k. This means we need to know the number of different pieces of information contained in the server CkC_k in the end.

Output Format

Write QQ lines to the standard output. The kk-th line (1kQ1 \le k \le Q) should contain an integer, the number of different pieces of information contained in the server CkC_k in the end.

5 6 3
1 2
1 3
2 4
2 5
1
2
1
4
4
3
1
4
5
3
5
4

Hint

Sample Explanation 1

In the beginning, we assume the server ii (1i51 \le i \le 5) contains the piece ii of information.

  • At time 1, the line 1 is built and the servers 1, 2 become connected. Then, both of the servers 1, 2 contain the pieces 1, 2 of information.
  • At time 2, the line 2 is built, and the server 1, 3 become connected. Including the line 1, the servers 1, 2, 3 are connected. The servers 1, 2, 3 contain the pieces 1, 2, 3 of information.
  • At time 3, the line 1 becomes unavailable because it was available just before this moment.
  • At time 4, the line 4 is built and the servers 2, 5 become connected. Both of the servers 2, 5 contain the pieces 1, 2, 3, 5 of information. Note that the servers 1, 2 cannot exchange pieces of information each other because the line 1 became unavailable.
  • At time 5, the line 4 becomes unavailable.
  • At time 6, the line 3 is built and the servers 2, 4 become connected. Then, both of the servers 2, 4 contain the pieces 1, 2, 3, 4, 5 of information.

As explained above, in the end, the servers 1, 4, 5 have 3, 5, 4 different pieces of information, respectively.

Constraints

All input data satisfy the following conditions.

  • 2N1000002 \le N \le 100\,000.
  • 1M2000001 \le M \le 200\,000.
  • 1QN1 \le Q \le N.
  • 1XiN1 \le X_i \le N, 1YiN1 \le Y_i \le N, XiYiX_i \ne Y_i (1iN11 \le i \le N - 1).
  • 1DjN11 \le D_j \le N - 1 (1jM1 \le j \le M).
  • 1CkN1 \le C_k \le N (1kQ1 \le k \le Q).
  • The values of CkC_k are distinct.
  • If all of the lines are built, there will be a route from one server to another server through the lines.

Subtask

Subtask1 [30 points]

  • Q=1Q = 1 is satisfied.

Subtask2 [30 points]

  • Xi=iX_i = i, Yi=i+1Y_i = i + 1 (1iN11 \le i \le N - 1) are satisfied.

Subtask3 [40 points]

There are no additional constraints.