int n,m,p,f[5010];
int find(int x)
{
if(f[x]!=x) f[x]=find(f[x]);
return f[x];
}
int main()
{
scanf("%d %d %d",&n,&m,&p);
for(int i=1;i<=n;i++) f[i]=i;
for(int i=1;i<=m;i++)
{
int x,y,fx,fy; scanf("%d %d",&x,&y);
fx=find(x); fy=find(y);
if(fx!=fy) f[fx]=fy;
}
for(int i=1;i<=p;i++)
{
int x,y; scanf("%d %d",&x,&y);
if(find(x)==find(y)) printf("Yes\n");
else printf("No\n");
}
return 0;
}
int n, m, a, b, q, f[5005];
int find(int u) {
if(f[u] == u) return u;
else return f[u] = find(f[u]);
}
void join(int x, int y) {
f[find(y)] = find(x);
return;
}
int main() {
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; i++)
f[i] = i;
for(int i = 1; i <= m; i++) {
scanf("%d%d", &a, &b);
join(a, b);
}
for(int i = 1; i <= q; i++) {
scanf("%d%d", &a, &b);
if(find(a) == find(b)) puts("Yes");
else puts("No");
}
return 0;
}
http://bible.com/events/5510833
http://bible.com/events/5510834
http://bible.com/events/5510838
http://bible.com/events/5510840
http://bible.com/events/5510841
http://bible.com/events/5510842
http://bible.com/events/5510844
http://bible.com/events/5510845
http://bible.com/events/5510850
http://bible.com/events/5510852
http://bible.com/events/5510855
http://bible.com/events/5510856
http://bible.com/events/5510857
http://bible.com/events/5510859
http://bible.com/events/5510860
http://bible.com/events/5510861
http://bible.com/events/5510862