n,m=map(int,input().split()) p=list(map(int,input().split())) for i in range(n): p[i]-=1 B=448 e=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 e[a]+=[b] e[b]+=[a] f=[len(e[i])>=B for i in range(n)] e2=[[] for i in range(n)] for s in range(n): for t in e[s]: if f[t]==1: e2[s]+=[t] c=[[] for i in range(n)] for s in range(n): if f[s]==1: c[s]=[0]*n for s in range(n): if f[s]==0: for t in e2[s]: c[t][p[s]]+=1 Q=int(input()) for _ in range(Q): x,y=map(int,input().split()) x-=1 y-=1 ok=0 if f[x]: if len(e2[x])>0: ok|=any(p[t]==p[y] for t in e2[x]) ok|=c[x][p[y]]!=0 else: ok|=any(p[t]==p[y] for t in e[x]) ok&=p[x]!=p[y] if ok: print("Yes") if f[x]==0: for t in e2[x]: c[t][p[x]]-=1 c[t][p[y]]+=1 p[x]=p[y] else: print("No")