#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; template< typename T > vector topological_sort(const vector> &G) { const int N = (int)G.size(); vector deg(N,0); for(int i = 0; i < N; i++){ for(auto &to : G[i]) ++deg[to]; } queue q; for(int i = 0; i < N; i++){ if(deg[i] == 0) q.push(i); } vector ord; while(!q.empty()){ int p = q.front(); q.pop(); ord.push_back(p); for(auto &to : G[p]){ if(--deg[to] == 0) q.push(to); } } return ord; // ord.size() == N => DAG } int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector A(N); rep(i,N) cin >> A[i]; vector> G(N); rep(i,M) { int u,v; cin >> u >> v; u--; v--; if(A[u] < A[v]) G[u].push_back(v); if(A[u] > A[v]) G[v].push_back(u); } int K; cin >> K; vector C(N, 0); rep(i,K) { int b; cin >> b; b--; C[b] = 1; } vector ans; vector ord = topological_sort(G); for(int v : ord) { if(C[v] == 1) { C[v] = 0; ans.push_back(v); for(int to : G[v]) { C[to] ^= 1; } } } int ok = 1; rep(i,N) ok &= (C[i] == 0); if(ok) { cout << ans.size() << endl; for(int a : ans) cout << a + 1 << "\n"; } else { cout << -1 << endl; } }