#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, p; cin >> n >> m >> p; int st, gol; cin >> st >> gol; st--; gol--; vector> g(n); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } const int INF = (int) 1e9; vector dist_fs(n, INF); vector dist_fg(n, INF); vector que = {st}; dist_fs[st] = 0; for (int i = 0; i < (int) que.size(); i++) { for (int j : g[que[i]]) { if (dist_fs[j] != INF) continue; dist_fs[j] = dist_fs[que[i]] + 1; que.push_back(j); } } que.clear(); que.push_back(gol); dist_fg[gol] = 0; for (int i = 0; i < (int) que.size(); i++) { for (int j : g[que[i]]) { if (dist_fg[j] != INF) continue; dist_fg[j] = dist_fg[que[i]] + 1; que.push_back(j); } } vector ans; for (int i = 0; i < n; i++) { if (dist_fs[i] == INF || dist_fg[i] == INF) continue; int d = dist_fg[i] + dist_fs[i]; if (d > p) continue; if ((p - d) % 2 == 0) ans.push_back(i); } if (ans.empty()) { cout << -1 << endl; return 0; } cout << ans.size() << '\n'; for (auto& x : ans) cout << x + 1 << '\n'; return 0; }