1194: 亲戚

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

题目描述

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

规定:lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> 是亲戚,lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> 是亲戚,那么 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> 也是亲戚。如果 lns="http://www.w3.org/1998/Math/MathML">lns="http://www.w3.org/1998/Math/MathML"> 是亲戚,那么 lns="http://www.w3.org/1998/Math/MathML"> 的亲戚都是 lns="http://www.w3.org/1998/Math/MathML"> 的亲戚,lns="http://www.w3.org/1998/Math/MathML"> 的亲戚也都是 lns="http://www.w3.org/1998/Math/MathML"> 的亲戚。

输入

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

以下 lns="http://www.w3.org/1998/Math/MathML"> 行:每行两个数 lns="http://www.w3.org/1998/Math/MathML">lns="http://www.w3.org/1998/Math/MathML">lns="http://www.w3.org/1998/Math/MathML">1, ,表示 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> 具有亲戚关系。

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

输出

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

样例输入

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

样例输出

Yes
Yes
No