#include using namespace std; using ll = long long; int main(){ int N, M, Q, A, B, K; cin >> N >> M; K = sqrt(M); vector P(N), lg; vector large(N); for (int i=0; i> P[i]; P[i]--; } vector> E(N); for (int i=0; i> A >> B; A--; B--; if (A == B) continue; E[A].push_back(B); E[B].push_back(A); } vector> cnt(N); for (int i=0; i= K){ large[i] = 1; lg.push_back(i); } } for (auto i : lg){ cnt[i].resize(N); for (auto x : E[i]){ if (!large[x]) cnt[i][P[x]]++; } } cin >> Q; while(Q){ Q--; bool f=0; cin >> A >> B; A--; B--; if (P[A] == P[B]){ cout << "No" << endl; continue; } if (!large[A]){ for (auto x : E[A]){ if (P[x] == P[B]) f=1; } if (f){ for (auto x : E[A]){ if (large[x]){ cnt[x][P[A]]--; cnt[x][P[B]]++; } } P[A] = P[B]; cout << "Yes" << endl; } else cout << "No" << endl; } else{ for (auto x : lg) if (P[x] == P[B]) f=1; if (cnt[A][P[B]] > 0) f=1; if (f){ cout << "Yes" << endl; P[A] = P[B]; } else cout << "No" << endl; } } return 0; }