#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* template */ using size_t = std::size_t; using i64 = std::int_fast64_t; using u64 = std::uint_fast64_t; using pii = std::pair; using pll = std::pair; template using vec = std::vector; template using pq = std::priority_queue, std::greater>; #ifdef LOCAL #define debug(...) \ std::cerr << "LINE: " << __LINE__ << " [" << #__VA_ARGS__ << "]:", \ debug_out(__VA_ARGS__) #else #define debug(...) #endif void debug_out() { std::cerr << std::endl; } template void debug_out(Head h, Tail... t) { std::cerr << " " << h; if (sizeof...(t) > 0) std::cout << " :"; debug_out(t...); } template std::ostream& operator<<(std::ostream& os, std::pair pa) { return os << pa.first << " " << pa.second; } template std::ostream& operator<<(std::ostream& os, std::vector vec) { for (std::size_t i = 0; i < vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } #define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++) #define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--) #define Rep(i, a, n) for (i64 i = (i64)(a); i< (i64)(n); i++) #define RRep(i, a, n) for (i64 i = ((i64)(n-i64(1))); i>=(i64)(a); i--) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() template void fill(std::vector &v) { for(T &e: v) std::cin >> e; } namespace ebi { template struct Edge { int to; T cost; Edge(int to, T cost) : to(to), cost(cost) { } }; template using Graph = std::vector>>; using graph = std::vector>; } 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; } template T lcm(T a, T b){ return (a*b)/std::gcd(a,b); } template T Pow(T x, i64 n){ T res = 1; while(n>0){ if(n&1) res = res *x; x = x*x; n>>=1; } return res; } constexpr i64 LNF = std::numeric_limits::max()/4; constexpr int INF = std::numeric_limits::max()/4; const long double PI=acos(-1); const std::vector dy = {1,0,-1,0,1,1,-1,-1}; const std::vector dx = {0,1,0,-1,1,-1,1,-1}; /* template */ int main(){ std::cout << std::fixed << std::setprecision(15); std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n,m; std::cin >> n >> m; std::vector a(n); std::vector idx(n); rep(i,0,n) { std::cin >> a[i]; idx[i] = i; } std::sort(all(idx), [&](int i, int j) { return a[i] < a[j]; }); ebi::graph g(n); rep(i,0,m) { int u,v; std::cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } int k; std::cin >> k; std::vector seen(n, -1); rep(i,0,k) { int b; std::cin >> b; b--; seen[b] = 1; } std::vector ans; rep(i,0,n) { int v = idx[i]; if(seen[v] < 0) continue; ans.emplace_back(v+1); for(auto nv: g[v]) { if(a[nv] <= a[v]) continue; seen[nv] *= -1; } } std::cout << ans.size() << std::endl; for(auto val: ans) { std::cout << val << std::endl; } }