#include<iostream>
using namespace std;
int height[ 100 ];
int root[ 100 ];
int find_root( int x ) {
//只有根节点存在x == root[ x ]
if( x != root[ x ] ) {
root[ x ] = find_root( root[ x ] );
}
return root[ x ];
}
void Union( int a , int b ) {
//低树并入高树
if( height[ a ] > height[ b ] ) {
root[ b ] = a;
}
else {
root[ a ] = b;
//如果树一样高,则高度加1
if( height[ a ] == height[ b ] ) {
height[ a ] ++;
}
}
}
int main() {
//有m个人,其中有q对亲戚,判断另外p对是否是亲戚
int m , q , p;
int a , b;
//输入,总共人数,给出的亲戚对数,以及问题数
cin >> m >> p >> q;
for( a = 0 ; a <= m ; a ++ ) {
height[ a ] = 0;
root[ a ] = a;
}
while( p -- ) {
//输入a和b是亲戚
cin >> a >> b;
//合并是对根的合并
Union( find_root( a ) , find_root( b ) );
}
while( q -- ) {
//判断a和b是否是亲戚
cin >> a >> b;
if( find_root( a ) == find_root( b ) ) {
cout << "YES" << endl;
}
else {
cout << "NO\n";
}
}
}
/*
10 5 5
1 2
2 5
3 6
7 3
8 9
1 3
2 4
5 6
5 5
6 7
*/