#P2256. 一中校运会之百米跑

一中校运会之百米跑

Description

Suppose there are NN (2N2×1042\leq N\leq 2\times 10^4) competitors.

The teacher will tell you the names of these NN competitors.

Then the teacher will say MM (1M1061\leq M\leq 10^6) sentences, each stating that student A and student B are in the same group.

If student A and student B are in the same group, and student B and student C are also in the same group, then student A and student C are in the same group.

After that, the teacher will ask you KK (1K1061\leq K\leq 10^6) questions, each asking whether student X and student Y are in the same group.

If they are, output Yes.; otherwise, output No..

Input Format

The first line contains NN and MM.

The next NN lines each contain the name of one student.

The next MM lines each contain two names, both guaranteed to have appeared in the above NN lines, indicating that these two competitors are in the same group.

Then an integer KK is given.

Then follow KK queries. Each query consists of two names, asking whether the two students are in the same group.

Output Format

For each of the teacher’s KK queries, output Yes. or No..

10 6
Jack
Mike
ASDA
Michel
brabrabra
HeHe
HeHE
papapa
HeY
Obama
Jack Obama
HeHe HeHE
brabrabra HeHe
Obama ASDA
papapa Obama
Obama HeHE
3
Mike Obama
HeHE Jack
papapa brabrabra

No.
Yes.
Yes.

Hint

Translated by ChatGPT 5