1559:亲戚关系

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:11 解决:10

题目描述

若某个家族人员过于庞大,要判断两个是否是亲戚,确实还很不容易,现在给出某个亲戚关系图,求任意给出的两个人是否具有亲戚关系。

规定:x 和 y 是亲戚,y 和 z 是亲戚,那么 x 和 z 也是亲戚。如果 x,y 是亲戚,那么 x 的亲戚都是 y 的亲戚,y 的亲戚也都是 x 的亲戚。

输入

第一行:三个整数 lns="http://www.w3.org/1998/Math/MathML">n,m,p,(lns="http://www.w3.org/1998/Math/MathML">n,m,p \le 5000),分别表示有 lns="http://www.w3.org/1998/Math/MathML">n 个人,lns="http://www.w3.org/1998/Math/MathML">m 个亲戚关系,询问 lns="http://www.w3.org/1998/Math/MathML">p 对亲戚关系。

以下 lns="http://www.w3.org/1998/Math/MathML">m 行:每行两个数 lns="http://www.w3.org/1998/Math/MathML">M_ilns="http://www.w3.org/1998/Math/MathML">M_jlns="http://www.w3.org/1998/Math/MathML">1 \le M_i,~M_j\le N,表示 lns="http://www.w3.org/1998/Math/MathML">M_i 和 lns="http://www.w3.org/1998/Math/MathML">M_j 具有亲戚关系。

接下来 lns="http://www.w3.org/1998/Math/MathML">p 行:每行两个数 lns="http://www.w3.org/1998/Math/MathML">P_i,P_j,询问 lns="http://www.w3.org/1998/Math/MathML">P_i 和 lns="http://www.w3.org/1998/Math/MathML">P_j 是否具有亲戚关系。

输出

 行,每行一个 Yes 或 No。表示第 lns="http://www.w3.org/1998/Math/MathML">i 个询问的答案为“具有”或“不具有”亲戚关系。

样例输入-1 复制

6 5 3
1 2
1 5
3 4
5 2
1 3
1 4
2 3
5 6

样例输出-1 复制

Yes
Yes
No