#include using namespace std; int main () { int N, M; scanf(" %d %d", &N, &M); std::vector A(N); for (auto& a : A) scanf(" %d", &a); vector> gr(N); for (int i = 0; i < M; i ++) { int a, b; scanf(" %d %d", &a, &b); gr[--a].push_back(--b); gr[b].push_back(a); } int s = max(1, (int)sqrt(M)); vector> bb(N); vector> X(N); for (int i = 0; i < N; i ++) { if (gr[i].size() > s) { for (auto v : gr[i]) { bb[v].push_back(i); } } else { for (auto v : gr[i]) { X[v][A[i]] ++; } } } int Q; scanf(" %d", &Q); while (Q--) { int x, y; scanf(" %d %d", &x, &y); x --; y --; if (A[x] == A[y]) { puts("No"); continue; } int a = A[y]; bool ok = false; if (X[x][a] > 0) { ok = true; } else { for (auto v : bb[x]) { ok = ok || (a == A[v]); } } if (ok) { puts("Yes"); if (gr[x].size() <= s) { for (auto v : gr[x]) { X[v][A[x]] --; X[v][a] ++; } } A[x] = a; } else { puts("No"); } } }