#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); } vector dist_s(n << 1, -1); vector que = {st << 1}; dist_s[st << 1] = 0; for (int i = 0; i < (int) que.size(); i++) { int cur = que[i] >> 1; int d = dist_s[que[i]] + 1; for (int j : g[cur]) { int nxt = (j << 1) + d % 2; if (dist_s[nxt] != -1) continue; dist_s[nxt] = d; que.push_back(nxt); } } vector dist_g(n << 1, -1); que = {gol << 1}; dist_g[gol << 1] = 0; for (int i = 0; i < (int) que.size(); i++) { int cur = que[i] >> 1; int d = dist_g[que[i]] + 1; for (int j : g[cur]) { int nxt = (j << 1) + d % 2; if (dist_g[nxt] != -1) continue; dist_g[nxt] = d; que.push_back(nxt); } } vector ans; for (int i = 0; i < n; i++) { int c = i << 1; for (int u = 0; u < 2; u++) for (int v = 0; v < 2; v++) { if (dist_s[c + u] != -1 && dist_g[c + v] != -1 && (u + v) % 2 == p % 2 && dist_s[c + u] + dist_g[c + v] <= p) { ans.push_back(i); continue; } } } if (!ans.empty()) { cout << ans.size() << '\n'; for (auto x : ans) cout << x + 1 << '\n'; } else { cout << -1 << '\n'; } return 0; }