import sys import math input = sys.stdin.readline #sys.setrecursionlimit(10000000) def read_values(): return map(int, input().split()) def read_index(): return map(lambda x: int(x) - 1, input().split()) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for _ in range(N)] def main(): N,M=read_values() P=read_list() pb=[[0]*(N//64+1) for _ in range(N)] for i in range(N): P[i]-=1 pb[P[i]][i//64]^=1<<(i%64) fb=[[0]*(N//64+1) for _ in range(N)] for i in range(M): A,B=read_index() fb[A][B//64]^=1<<(B%64) fb[B][A//64]^=1<<(A%64) Q = int(input()) for _ in range(Q): X,Y=read_index() if P[X]==P[Y] or all(f&p==0 for f,p in zip(fb[X],pb[P[Y]])): print("No") else: print("Yes") pb[P[X]][X//64]^=1<<(X%64) pb[P[Y]][X//64]^=1<<(X%64) P[X]=P[Y] if __name__ == "__main__": main()