import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 class dsu(): n=1 parent_or_size=[-1 for i in range(n)] def __init__(self,N): self.n=N self.num = N self.parent_or_size=[-1 for i in range(N)] def merge(self,a,b): assert 0<=a0: result2.append(result[i]) return result2 def count(self): return self.num n, m = mi() if m > 50000: nowworld = [v - 1 for v in li()] #n人の今いるワールド worldleaderlist = [Counter() for _ in range(n)] U = dsu(n) for _ in range(m): u, v = mi() u -= 1; v -= 1 U.merge(u, v) for i in range(n): worldleaderlist[nowworld[i]][U.leader(i)] += 1 for _ in range(ii()): x, y = mi() x -= 1; y -= 1 if nowworld[x] != nowworld[y] and worldleaderlist[nowworld[y]][U.leader(x)] > 0: print('Yes') worldleaderlist[nowworld[x]][U.leader(x)] -= 1 nowworld[x] = nowworld[y] worldleaderlist[nowworld[x]][U.leader(x)] += 1 else: print('No') else: nowworld = [v - 1 for v in li()] #n人の今いるワールド worldlist = [set() for _ in range(n)] for i in range(n): worldlist[nowworld[i]].add(i) graph = [set() for _ in range(n)] for _ in range(m): u, v = mi() u -= 1; v -= 1 graph[u].add(v) graph[v].add(u) def common(x, y): if len(graph[x]) < len(worldlist[nowworld[y]]): for v in graph[x]: if v in worldlist[nowworld[y]]: return True return False else: for v in worldlist[nowworld[y]]: if v in graph[x]: return True return False for _ in range(ii()): x, y = mi() x -= 1; y -= 1 if nowworld[x] != nowworld[y] and common(x, y): worldlist[nowworld[x]].discard(x) nowworld[x] = nowworld[y] worldlist[nowworld[x]].add(x) print('Yes') else: print('No')