#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template using pq = priority_queue, greater>; int main(){ long long N, M, A, B, C, start, K; long long from, alt, d; cin >> N >> M; pq> que; vector num(N), ans; deque color(N); for (int i=0; i> num[i]; vector> E(N); for (int i=0; i < M; i++){ cin >> A >> B; A--; B--; E[A].push_back(B); E[B].push_back(A); } cin >> K; for (int i=0; i> B; B--; color[B] = 1; que.push({num[B], B}); } while(!que.empty()){ tie(d, from) = que.top(); que.pop(); color[from] = 0; ans.push_back(from+1); for (auto to : E[from]){ if (num[to] > num[from]){ color[to] ^= 1; if (color[to] == 1){ que.push({num[to], to}); } } } } cout << ans.size() << endl; for (auto x : ans) cout << x << endl; return 0; }