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) def solve(X,Y): if P[X]==P[Y]: return False for i in range(N//64+1): if fb[X][i]&pb[P[Y]][i]!=0: return True return False Q = int(input()) for _ in range(Q): X,Y=read_index() if solve(X,Y): print("Yes") pb[P[X]][X//64]^=1<<(X%64) pb[P[Y]][X//64]^=1<<(X%64) P[X]=P[Y] else: print("No") if __name__ == "__main__": main()