#include #include #include #include int a[100000], *g[100000], d[100000], s[100000], x[100000], c[100000]; bool l[100000]; void push_back(int i, int x) { if (d[i] == 0) { c[i] = 1; g[i] = malloc(sizeof(int)); } else if (d[i] == c[i]) { g[i] = realloc(g[i], sizeof(int) * c[i] * 2); c[i] *= 2; } g[i][d[i]] = x; ++d[i]; } int comp(const void *x, const void *y) { return a[*(const int *)x] - a[*(const int *)y]; } int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); g[i] = NULL; d[i] = 0; s[i] = i; } qsort(&s[0], n, sizeof(int), comp); for (int i = 0; i < m; ++i) { int u, v; scanf("%d %d", &u, &v); --u; --v; push_back(u, v); push_back(v, u); } int k; scanf("%d", &k); while (k--) { int b; scanf("%d", &b); --b; l[b] = true; } int *last = &x[0]; for (int i = 0; i < n; ++i) { int v = s[i]; if (!l[v]) { continue; } *last++ = v; for (int j = 0; j < d[v]; ++j) { int u = g[v][j]; if (a[v] < a[u]) { l[u] = !l[u]; } } } printf("%ld\n", last - &x[0]); int *iter = &x[0]; while (iter != last) { printf("%d\n", *iter++ + 1); } }