import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, m = map(int, input().split()) A = list(map(int, input().split())) g = [[] for i in range(n)] for i in range(m): u, v = map(int, input().split()) u, v = u-1, v-1 if A[u] < A[v]: g[u].append(v) elif A[u] > A[v]: g[v].append(u) k = int(input()) B = list(map(int, input().split())) B = [b-1 for b in B] C = [0]*n for b in B: C[b] = 1 q = [] import heapq for b in B: q.append((A[b], b)) ans = [] while q: a, v =heapq.heappop(q) if C[v] == 0: continue ans.append(v+1) for u in g[v]: C[u] = 1-C[u] q.append((A[u], u)) print(len(ans)) print(*ans, sep='\n')