Jail

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

문제

In JOI Kingdom, the security of IOI Jail is strictly controlled. There are NN rooms in IOI Jail, numbered from 11 to NN. There are N1N - 1 passages connecting rooms. The passage ii (1iN11 ≤ i ≤ N - 1) connects the room A_iA\_i and the room B_iB\_i bidirectionally. It is possible to move from any room to any other room by passing through several passages.

There are MM prisoners in IOI Jail. Each prisoner has a “ID number”, which is an integer between 11 and MM, inclusive. The bedroom of the prisoner jj (1jM1 ≤ j ≤ M) is the room S_jS\_j, and the workroom of the prisoner jj is the room T_jT\_j. A prisoner may work in the bedroom of another prisoner. However, no two prisoners share the same bedroom, and no two prisoners share the same workroom.

One morning, the MM prisoners have to move from their bed rooms to their work rooms. Mr. APIO is the director of IOI Jail. He will give the following directions to the prisoners to move.

Direction Choose a prisoner, and move the chosen prisoner from the current room to another room which is connected with the current room by a passage. In order to avoid communication between prisoners, it is not allowed to move the prisoner to a room where another prisoner stays.

In order to start work as early as possible, Mr. APIO wants to know whether it is possible to give directions so that every prisoner does not pass through the same room more than once (it means that every prisoner takes a shortest path).

Write a program which, given information of the rooms and the passages in IOI Jail and information on the prisoners, determines whether it is possible to move the prisoners so that every prisoner takes a shortest path.

입력

A test case consists of Q scenarios, numbered from 1 to Q. The following values are specified for each scenario. For the range of these values, see Constraints.

  • The number of rooms NN in IOI Jail.
  • Information on the passages in IOI Jail (A_1,B_1)(A\_1, B\_1), (A_2,B_2)(A\_2, B\_2), \cdots, (A_N1,B_N1)(A\_{N-1}, B\_{N-1}).
  • The number of prisoners MM in IOI Jail.
  • Information on the bedrooms and the workrooms of the prisoners (S_1,T_1)(S\_1, T\_1), (S_2,T_2)(S\_2, T\_2), \cdots, (S_M,T_M)(S\_M, T\_M).

The format of the input data is as follows. Given values are all integers.

QQ

(Input for Scenario 11)

(Input for Scenario 22)

. . .

(Input for Scenario QQ)

The format of the input data for each scenario is as follows. See Sample Input and Output for details.

\begin{align\*}& N \\\ & A\_1\\,B\_1 \\\ & A\_2 \\, B\_2 \\, \\\ & \vdots \\\ & A\_{N-1} \\, B\_{N-1} \\\ & M \\\ & S\_1 \\, T\_1 \\\ & S\_2 \\, T\_2 \\\ & \vdots \\\ & S\_M \\, T\_M\end{align\*}

출력

Write QQ lines to the standard output.

The kk-th line (1kQ1 ≤ k ≤ Q) should contain the following.

  • Yes if it is possible to move the prisoners for the scenario kk.
  • No if it is not possible to move the prisoners for the scenario kk.

제한

  • 1Q1,0001 ≤ Q ≤ 1\\,000.
  • 2N120,0002 ≤ N ≤ 120\\,000.
  • 1A_i<B_iN1 ≤ A\_i < B\_i ≤ N (1iN11 ≤ i ≤ N - 1).
  • 2MN2 ≤ M ≤ N.
  • 1S_jN1 ≤ S\_j ≤ N (1 jM1 ≤ j ≤ M).
  • 1T_jN1 ≤ T\_j ≤ N (1jM1 ≤ j ≤ M).
  • S_1,S_2, ,S_MS\_1, S\_2, \cdots  , S\_M are different from each other.
  • T_1,T_2,,T_MT\_1, T\_2, \cdots , T\_M are different from each other.
  • S_jT_jS\_j \ne T\_j (1jM1 ≤ j ≤ M).
  • It is possible to move from any room to any other room by passing through several passages.
  • The sum of NN for the QQ scenarios is less than or equal to 120,000120\\,000.