#T301. 亲戚

亲戚

Description

Perhaps you are unaware that one of your friends might actually be your relative. He could be the grandson of your great-great-grandfather's son-in-law's niece's cousin's daughter. If we had access to a complete family tree, determining whether two people are relatives would be feasible. However, if their most recent common ancestor is several generations removed, making the family tree extremely large, verifying kinship would be beyond human capability.

In such cases, the best solution is to rely on computers. To simplify the problem, you will be given some information about kinship 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 can answer our kinship queries as quickly as possible.

Input Format

The input consists of two parts.
The first part starts with two integers, N and M. N is the number of people involved in the problem (1 ≤ N ≤ 20000). These people are numbered 1, 2, 3, ..., N. The following M lines (1 ≤ M ≤ 1000000) each contain two integers, aia_i and bib_i, indicating that aia_i and bib_i are known relatives.

The second part starts with an integer Q. The next Q lines (1 ≤ Q ≤ 1000000) each contain two integers, cic_i and did_i, representing a query asking whether cic_i and did_i are relatives.

Output Format

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

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

Yes
No
Yes