N,M=map(int, input().split()) A=list(map(int, input().split())) G=[[]for i in range(N)] deg=[0]*N for i in range(M): a,b=map(int, input().split()) a-=1 b-=1 if A[a]A[b]: G[b].append(a) deg[a]+=1 V=N # V:頂点数 # G[v] = [w, ...]:有向グラフ上の頂点vから到達できる頂点w # deg[v]:頂点vに到達できる頂点の数 from collections import deque ans = list(v for v in range(V) if deg[v] == 0) deq = deque(ans) used = [0] * V while deq: v=deq.popleft() for t in G[v]: deg[t]-=1 if deg[t]==0: deq.append(t) ans.append(t) L=[0]*N K=int(input()) B=list(map(int, input().split())) for b in B: L[b-1]=1 F=[] for i in ans: if L[i]==1: F.append(i+1) for nex in G[i]: L[nex]=1-L[nex] print(len(F)) for f in F: print(f)