#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, p, s, g; cin >> n >> m >> p >> s >> g; --s, --g; vector> graph(n); for(int i = 0; i < m; ++i){ int u, v; cin >> u >> v; --u, --v; graph[u].emplace_back(v); graph[v].emplace_back(u); } // dist[vertex][parity] auto bfs = [&](int root) -> vector> { vector> dist(n, vector(2, INF)); queue

que; dist[root][0] = 0; que.emplace(root, 0); while(!que.empty()){ auto [from, parity] = que.front(); que.pop(); for(int to : graph[from]){ if(chmin(dist[to][parity ^ 1], dist[from][parity] + 1)){ que.emplace(to, parity ^ 1); } } } return dist; }; auto dists = bfs(s); auto distg = bfs(g); set ans; // s -> v -> g for(int v = 0; v < n; ++v){ for(int i = 0; i < 2; ++i){ for(int j = 0; j < 2; ++j){ if((i ^ j) != p % 2) continue; int d = dists[v][i] + distg[v][j]; if(d <= p && (p - d) % 2 == 0){ ans.emplace(v); } } } } // s -> g -> v -> g for(int i = 0; i < 2; ++i){ if(dists[g][i] > p) continue; int q = p - dists[g][i]; for(int v = 0; v < n; ++v){ for(int j = 0; j < 2; ++j){ for(int k = 0; k < 2; ++k){ if((j ^ k) != q % 2) continue; int d = distg[v][j] + distg[v][k]; if(d <= q && (q - d) % 2 == 0){ ans.emplace(v); } } } } } if(ans.size() == 0) cout << -1 << '\n'; else{ cout << ans.size() << '\n'; for(int v : ans) cout << v + 1 << '\n'; } return 0; }