#include #include using namespace std; struct Graph { int n; std::vector> g; Graph(){} Graph(int n) : n(n){ g.resize(n); } void add_edge(int from, int to){ g[from].push_back(to); } }; int main() { int n, m; cin >> n >> m; int a[100005]; for(int i = 0; i < n; i++) cin >> a[i]; Graph g(n), r(n); for(int i = 0; i < m; i++){ int u, v; cin >> u >> v; u--; v--; if(a[u] < a[v]){ g.add_edge(u, v); r.add_edge(v, u); } if(a[u] > a[v]){ g.add_edge(v, u); r.add_edge(u, v); } } int k; cin >> k; bool b[100005]{0}; for(int i = 0; i < k; i++){ int u; cin >> u; u--; b[u] = true; } bool c[100005]{0}; queue que; for(int u = 0; u < n; u++){ if(r.g[u].size() == 0){ c[u] = true; que.push(u); } } vector ans; while(que.size()){ int u = que.front(); que.pop(); if(b[u]) ans.push_back(u); for(int v : g.g[u]){ if(b[u]) b[v] = !b[v]; if(!c[v]){ c[v] = true; que.push(v); } } } cout << (int)ans.size() << endl; for(int u : ans) cout << u + 1 << endl; cout << endl; }