#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("ttime.in");
ofstream fout("ttime.out");
#define cin fin
#define cout fout
int fa[100001];
int u_f(int x)
{
int root=x;
while(fa[root]!=root) root=fa[root];
while(fa[x]!=x)
{
int y=fa[x];
fa[x]=root;
x=y;
}
return root;
}
int main()
{
int n,m,q;
cin>>n>>m>>q;
for(int i=1;i<=n;i++)
fa[i]=i;
for(int i=0;i<m;i++)
{
int x,y;
cin>>x>>y;
int fx=u_f(x);
int fy=u_f(y);
if(fx!=fy)
fa[fy]=fx;
}
int x[q+1],y[q+1];
for(int i=0;i<q;i++)
cin>>x[i]>>y[i];
for(int i=0;i<q;i++)
if(u_f(x[i]) != u_f(y[i]))
cout<<"N\n";
else cout<<"Y\n";
return 0;
}