from sys import setrecursionlimit, stdin def find(parent, i): t = parent[i] if t < 0: return i t = find(parent, t) parent[i] = t return t def unite(parent, i, j): i = find(parent, i) j = find(parent, j) if i == j: return parent[j] += parent[i] parent[i] = j def bit_add(bit, i, x): i += 1 n = len(bit) while i <= n: bit[i - 1] += x i += i & -i def bit_sum(bit, i): result = 0 i += 1 while i > 0: result += bit[i - 1] i -= i & -i return result def query(bit, start, stop): if start == 0: return bit_sum(bit, stop - 1) else: return bit_sum(bit, stop - 1) - bit_sum(bit, start - 1) readline = stdin.readline setrecursionlimit(10 ** 6) N, M = map(int, readline().split()) A = list(map(int, readline().split())) a = sorted(set(A)) t = {} for i in range(N): t[a[i]] = i for i in range(N): A[i] = t[A[i]] parent = [-1] * N for _ in range(M): u, v = map(lambda x: int(x) - 1, readline().split()) unite(parent, u, v) K = int(readline()) B = set(map(lambda x: int(x) - 1, readline().split())) t = {} for i in range(N): p = find(parent, i) t.setdefault(p, []) t[p].append((A[i], i)) for k in t: t[k] = sorted(t[k]) result = [] for k in t: bit = [0] * N for a, i in t[k]: x = query(bit, 0, a) if i in B: x += 1 if x % 2 == 1: result.append(i + 1) bit_add(bit, a, 1) print(len(result)) print(*result, sep='\n')