#t523. 亲戚

亲戚

Relatives

Problem Background

Special for beginners, ^_^

Problem Description

You may not know it, but one of your friends is your relative. He could be the great-grandson of the nephew of your wife's cousin's daughter's grandson. If we had the complete family tree, it would be feasible to tell whether two people are relatives, but if the two people's lowest common ancestor is separated from them by several generations, making the family tree huge, then checking the relationship is beyond human power. In this case, the best helper is a computer. To simplify the problem, you will be given some information about relative relationships, such as Marry and Tom are relatives, Tom and Ben are relatives, and so on. From this information you can deduce that Marry and Ben are relatives. Please write a program that answers our questions about relative relationships as fast as possible.

Input Format

The input consists of two parts.

The first part begins with N,MN, M. NN is the number of people involved in the questions (1≤N≤200001 \le N \le 20000). These people are numbered 1,2,3,…,N1, 2, 3, \dots, N.

The following MM lines (1≤M≤10000001 \le M \le 1000000) each contain two numbers ai,bia_i, b_i, meaning aia_i and bib_i are known to be relatives.

The second part begins with QQ. The following QQ lines contain QQ queries (1≤Q≤10000001 \le Q \le 1000000), each line is ci,dic_i, d_i, asking whether cic_i and did_i are relatives.

Output Format

For each query ci,dic_i, d_i, output one line: if cic_i and did_i are relatives, output Yes; otherwise output No.

Sample Input

10 7
2 4
5 7
1 3
8 9
1 2
5 6
2 3
3
3 4
7 10
8 9

Sample Output

Yes
No
Yes

Constraints

Time limit: 1s; memory limit: 1024 KiB for each test case.