Tourism

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

JOI Kingdom is an insular country consisting of NN islands, numbered from 11 to NN. The islands are connected by N1N - 1 bridges, numbered from 11 to N1N - 1. The bridge ii (1iN11 ≤ i ≤ N - 1) connects the island A_iA\_i and the island B_iB\_i bidirectionally. It is possible to travel from any island to any other island by passing through a number of bridges.

In JOI Kingdom, there are MM sightseeing spots, numbered from 11 to MM. The sightseeing spot jj (1jM1 ≤ j ≤ M) is located in the island C_jC\_j.

There are QQ travelers. They plan to visit sightseeing spots in JOI Kingdom. The travelers are numbered from 11 to QQ. Each traveler makes a trip in the following way.

  1. The traveler chooses an island xx (1xN1 ≤ x ≤ N). Taking an airplane, the traveler arrives at the island xx.

  2. The traveler takes the following actions a number of times. The order and the kinds of actions are arbitrary.

    • The traveler chooses a sightseeing spot in the current island, and visits there.
    • The traveler moves to another island by passing through a bridge.
  3. Taking an airplane, the traveler leaves JOI Kingdom.

The traveler kk (1kQ1 ≤ k ≤ Q) wants to visit all of the sightseeing spots L_k,L_k+1,,R_kL\_k, L\_{k + 1}, \dots , R\_k. However, since the budget is limited, the traveler kk wants to minimize the number of islands where the traveler kk visits at least once.

Write a program which, given information of JOI Kingdom and the travelers, calculates, for each kk (1kQ1 ≤ k ≤ Q), the minimum possible number of islands where the traveler kk visits at least once.

입력

Read the following data from the standard input.

NN MM QQ

A_1A\_1 B_1B\_1

A_2A\_2 B_2B\_2

\vdots

A_N1A\_{N-1} B_N1B\_{N-1}

C_1C\_1 C_2C\_2 \cdots C_MC\_M

L_1L\_1 R_1R\_1

L_2L\_2 R_2R\_2

\vdots

L_QL\_Q R_QR\_Q

출력

Write QQ lines to the standard output. The kk-th line (1kQ1 ≤ k ≤ Q) of output should contain the minimum possible number of islands where the traveler kk visits at least once.

제한

  • 1N100,0001 ≤ N ≤ 100\\,000.
  • 1M100,0001 ≤ M ≤ 100\\,000.
  • 1Q100,0001 ≤ Q ≤ 100\\,000.
  • 1A_iN1 ≤ A\_i ≤ N (1iN11 ≤ i ≤ N - 1).
  • 1B_iN1 ≤ B\_i ≤ N (1iN11 ≤ i ≤ N - 1).
  • It is possible to travel from any island to any other island by passing through a number of bridges.
  • 1C_jN1 ≤ C\_j ≤ N (1jM1 ≤ j ≤ M).
  • 1L_kR_kM1 ≤ L\_k ≤ R\_k ≤ M (1kQ1 ≤ k ≤ Q).
  • Given values are all integers.