//基础太差,做题就像脑筋急转弯一样,想到了才能AC
#include <cstdio>
#include <cstring>
#define M 10005
using namespace std;
int map[M], num[M];
int main()
{
int n, m, k, t1, t2, cnt;
while (scanf("%d%d%d", &n, &m, &k) != EOF)
{
cnt = 0;
memset(map, -1, sizeof(map));
for (int i = 0; i < m; i++)
{
scanf("%d%d", &t1, &t2);
if (map[t1] == -1 && map[t2] == -1)
map[t1] = cnt, map[t2] = cnt++;
else if (map[t1] == -1 && map[t2] != -1)
map[t1] = map[t2];
else if (map[t1] != -1 && map[t2] == -1)
map[t2] = map[t1];
else
{
if (map[t1] != map[t2])
{
int tt1 = map[t1], tt2 = map[t2];
for (int j = 0; j < n; j++)
if (map[j] == tt1)
map[j] = tt2;
}
}
}
for (int i = 0; i < k; i++)
{
scanf("%d%d", &t1, &t2);
if (map[t1] == map[t2] && map[t1] != -1)
printf("YES\n");
else printf("NO\n");
}
}
}