#pragma GCC optimize("Ofast") //#ifndef ONLINE_JUDGE //#define _GLIBCXX_DEBUG //#endif #ifdef ONLINE_JUDGE #include #endif #include #include #include #include #include using namespace std; #ifdef ONLINE_JUDGE using namespace atcoder; #endif #define rep(i,n) for (int i = 0;i < (int)(n);i++) using ll = long long; #ifdef ONLINE_JUDGE //using mint = modint998244353; //using mint = modint; using mint = modint1000000007; #endif //const ll MOD=1000000007; const ll MOD=998244353; const long long INF = 1LL << 60; const double pi=acos(-1.0); int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // cout << fixed << setprecision(15); ll N,M; cin>>N>>M; vector A(N); rep(i,N) cin>>A[i]; vector> graph(N,vector(0)); vector deg(N,0); rep(_,M) { ll u,v; cin>>u>>v; u--; v--; if(A[u]==A[v]) continue; if(A[u]>A[v]) swap(u,v); graph[u].push_back(v); deg[v]++; } ll K; cin>>K; vector lamps(N,0); rep(_,K) { ll b; cin>>b; b--; lamps[b]=1; } vector anses(0); queue que; rep(v,N) if(!deg[v]) que.push(v); while(!que.empty()) { ll v=que.front(); que.pop(); if(lamps[v]) { anses.push_back(v); for(auto &nv:graph[v]) lamps[nv]^=1; } for(auto &nv:graph[v]) { deg[nv]--; if(!deg[nv]) que.push(nv); } } cout<