#P1551. 亲戚
亲戚
Description
Rules: If and are relatives, and and are relatives, then and are also relatives. If and are relatives, then all relatives of are also relatives of , and all relatives of are also relatives of .
Input Format
The first line contains three integers (), representing that there are people, kinship relations, and queries.
Each of the following lines contains two integers (), indicating that and are relatives.
Then the next lines each contain two integers , asking whether and are relatives.
Output Format
Output lines. Each line contains either Yes or No, indicating whether the answer to the -th query is “are relatives” or “are not relatives.”
6 5 3
1 2
1 5
3 4
5 2
1 3
1 4
2 3
5 6
Yes
Yes
No
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号