#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define SZ(S) ((int) ((S).size()))
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
vector< int > G[10111];
int V;
struct UndirectedDfs {
vector<int> low, num, parent;
vector<bool> articulation;
int counter, root, children;
vector< pair<int,int> > bridges;
vector<int> cuts;
UndirectedDfs() : low(V, 0), num(V, -1), parent(V, 0), articulation(V, false),
counter(0), children(0) {
for(int i = 0; i < V; ++i) if (num[i] == -1) {
root = i; children = 0;
dfs(i);
articulation[root] = (children > 1);
}
for(int i = 0; i < V; ++i)
if (articulation[i]) cuts.push_back(i);
}
private:
void dfs(int u) {
low[u] = num[u] = counter++;
for(int j = 0; j < G[u].size(); ++j) {
int v = G[u][j];
if (num[v] == -1) {
parent[v] = u;
if (u == root) children++;
dfs(v);
if (low[v] >= num[u])
articulation[u] = true;
if (low[v] > num[u]) bridges.push_back(make_pair(u, v));
low[u] = min(low[u], low[v]);
} else if (v != parent[u])
low[u] = min(low[u], num[v]);
}
}
};
int lab[10111];
int getRoot(int u) {
if (lab[u] < 0) return u;
return lab[u] = getRoot(lab[u]);
}
void merge(int u, int v) {
u = getRoot(u); v = getRoot(v);
if (u == v) return ;
lab[u] = lab[u] + lab[v];
lab[v] = u;
}
int main() {
ios :: sync_with_stdio(false); cin.tie(NULL);
cout << (fixed) << setprecision(6);
int n, m, q;
while (cin >> n >> m >> q && n) {
V = n;
REP(i,n) G[i].clear();
FOR(i,1,m) {
int u, v; cin >> u >> v;
--u; --v;
G[u].push_back(v);
G[v].push_back(u);
}
UndirectedDfs tree;
memset(lab, -1, sizeof lab);
for(auto p : tree.bridges) {
int u = p.first, v = p.second;
++u; ++v;
merge(u, v);
}
while (q--) {
int u, v; cin >> u >> v;
if (getRoot(u) == getRoot(v)) cout << 'Y';
else cout << 'N';
cout << "\n";
}
cout << "-\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIEZPUihpLGEsYikgZm9yKGludCBpPShhKSxfYj0oYik7IGk8PV9iOyBpKyspCiNkZWZpbmUgRk9SRChpLGEsYikgZm9yKGludCBpPShhKSxfYj0oYik7IGk+PV9iOyBpLS0pCiNkZWZpbmUgUkVQKGksYSkgZm9yKGludCBpPTAsX2E9KGEpOyBpPF9hOyBpKyspCiNkZWZpbmUgRUFDSChpdCxhKSBmb3IoX190eXBlb2YoYS5iZWdpbigpKSBpdCA9IGEuYmVnaW4oKTsgaXQgIT0gYS5lbmQoKTsgKytpdCkKI2RlZmluZSBTWihTKSAoKGludCkgKChTKS5zaXplKCkpKQoKI2RlZmluZSBERUJVRyh4KSB7IGNvdXQgPDwgI3ggPDwgIiA9ICIgPDwgeCA8PCBlbmRsOyB9CiNkZWZpbmUgUFIoYSxuKSB7IGNvdXQgPDwgI2EgPDwgIiA9ICI7IEZPUihfLDEsbikgY291dCA8PCBhW19dIDw8ICcgJzsgY291dCA8PCBlbmRsOyB9CiNkZWZpbmUgUFIwKGEsbikgeyBjb3V0IDw8ICNhIDw8ICIgPSAiOyBSRVAoXyxuKSBjb3V0IDw8IGFbX10gPDwgJyAnOyBjb3V0IDw8IGVuZGw7IH0KCnZlY3RvcjwgaW50ID4gR1sxMDExMV07CmludCBWOwoKc3RydWN0IFVuZGlyZWN0ZWREZnMgewogICAgdmVjdG9yPGludD4gbG93LCBudW0sIHBhcmVudDsKICAgIHZlY3Rvcjxib29sPiBhcnRpY3VsYXRpb247CiAgICBpbnQgY291bnRlciwgcm9vdCwgY2hpbGRyZW47CgogICAgdmVjdG9yPCBwYWlyPGludCxpbnQ+ID4gYnJpZGdlczsKICAgIHZlY3RvcjxpbnQ+IGN1dHM7CgogICAgVW5kaXJlY3RlZERmcygpIDogbG93KFYsIDApLCBudW0oViwgLTEpLCBwYXJlbnQoViwgMCksIGFydGljdWxhdGlvbihWLCBmYWxzZSksCiAgICAgICAgICAgIGNvdW50ZXIoMCksIGNoaWxkcmVuKDApIHsKICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgVjsgKytpKSBpZiAobnVtW2ldID09IC0xKSB7CiAgICAgICAgICAgIHJvb3QgPSBpOyBjaGlsZHJlbiA9IDA7CiAgICAgICAgICAgIGRmcyhpKTsKICAgICAgICAgICAgYXJ0aWN1bGF0aW9uW3Jvb3RdID0gKGNoaWxkcmVuID4gMSk7CiAgICAgICAgfQogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBWOyArK2kpCiAgICAgICAgICAgIGlmIChhcnRpY3VsYXRpb25baV0pIGN1dHMucHVzaF9iYWNrKGkpOwogICAgfQpwcml2YXRlOgogICAgdm9pZCBkZnMoaW50IHUpIHsKICAgICAgICBsb3dbdV0gPSBudW1bdV0gPSBjb3VudGVyKys7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IEdbdV0uc2l6ZSgpOyArK2opIHsKICAgICAgICAgICAgaW50IHYgPSBHW3VdW2pdOwogICAgICAgICAgICBpZiAobnVtW3ZdID09IC0xKSB7CiAgICAgICAgICAgICAgICBwYXJlbnRbdl0gPSB1OwogICAgICAgICAgICAgICAgaWYgKHUgPT0gcm9vdCkgY2hpbGRyZW4rKzsKICAgICAgICAgICAgICAgIGRmcyh2KTsKICAgICAgICAgICAgICAgIGlmIChsb3dbdl0gPj0gbnVtW3VdKQogICAgICAgICAgICAgICAgICAgIGFydGljdWxhdGlvblt1XSA9IHRydWU7CiAgICAgICAgICAgICAgICBpZiAobG93W3ZdID4gbnVtW3VdKSBicmlkZ2VzLnB1c2hfYmFjayhtYWtlX3BhaXIodSwgdikpOwogICAgICAgICAgICAgICAgbG93W3VdID0gbWluKGxvd1t1XSwgbG93W3ZdKTsKICAgICAgICAgICAgfSBlbHNlIGlmICh2ICE9IHBhcmVudFt1XSkKICAgICAgICAgICAgICAgIGxvd1t1XSA9IG1pbihsb3dbdV0sIG51bVt2XSk7CiAgICAgICAgfQogICAgfQp9OwoKaW50IGxhYlsxMDExMV07CgppbnQgZ2V0Um9vdChpbnQgdSkgewogICAgaWYgKGxhYlt1XSA8IDApIHJldHVybiB1OwogICAgcmV0dXJuIGxhYlt1XSA9IGdldFJvb3QobGFiW3VdKTsKfQp2b2lkIG1lcmdlKGludCB1LCBpbnQgdikgewogICAgdSA9IGdldFJvb3QodSk7IHYgPSBnZXRSb290KHYpOwogICAgaWYgKHUgPT0gdikgcmV0dXJuIDsKICAgIGxhYlt1XSA9IGxhYlt1XSArIGxhYlt2XTsKICAgIGxhYlt2XSA9IHU7Cn0KCmludCBtYWluKCkgewogICAgaW9zIDo6IHN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7CiAgICBjb3V0IDw8IChmaXhlZCkgPDwgc2V0cHJlY2lzaW9uKDYpOwogICAgaW50IG4sIG0sIHE7CiAgICB3aGlsZSAoY2luID4+IG4gPj4gbSA+PiBxICYmIG4pIHsKICAgICAgICBWID0gbjsKICAgICAgICBSRVAoaSxuKSBHW2ldLmNsZWFyKCk7CiAgICAgICAgRk9SKGksMSxtKSB7CiAgICAgICAgICAgIGludCB1LCB2OyBjaW4gPj4gdSA+PiB2OwogICAgICAgICAgICAtLXU7IC0tdjsKICAgICAgICAgICAgR1t1XS5wdXNoX2JhY2sodik7CiAgICAgICAgICAgIEdbdl0ucHVzaF9iYWNrKHUpOwogICAgICAgIH0KICAgICAgICBVbmRpcmVjdGVkRGZzIHRyZWU7CiAgICAgICAgbWVtc2V0KGxhYiwgLTEsIHNpemVvZiBsYWIpOwogICAgICAgIGZvcihhdXRvIHAgOiB0cmVlLmJyaWRnZXMpIHsKICAgICAgICAgICAgaW50IHUgPSBwLmZpcnN0LCB2ID0gcC5zZWNvbmQ7CiAgICAgICAgICAgICsrdTsgKyt2OwogICAgICAgICAgICBtZXJnZSh1LCB2KTsKICAgICAgICB9CgogICAgICAgIHdoaWxlIChxLS0pIHsKICAgICAgICAgICAgaW50IHUsIHY7IGNpbiA+PiB1ID4+IHY7CiAgICAgICAgICAgIGlmIChnZXRSb290KHUpID09IGdldFJvb3QodikpIGNvdXQgPDwgJ1knOwogICAgICAgICAgICBlbHNlIGNvdXQgPDwgJ04nOwogICAgICAgICAgICBjb3V0IDw8ICJcbiI7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgIi1cbiI7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK