#include using namespace std; using Graph = vector>; set ans; set s; bool f[101010]; void dfs(Graph &g, vector d, int v){ if (s.find(v) != s.end()){ for (int i : d){ ans.insert(i); } } for (int i : g[v]){ if (!f[i]){ f[i] = true; d.push_back(i); dfs(g, d, i); d.pop_back(); } } } int main() { int n, m, p; cin >> n >> m >> p; int S, G; cin >> S >> G; S--; G--; Graph 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 d(n, -1); d[S] = 0; queue q; q.push(S); while (!q.empty()){ int v = q.front(); q.pop(); for (int i : g[v]){ if (d[i] == -1){ d[i] = d[v] + 1; q.push(i); } } } vector d2(n, -1); d2[G] = 0; queue q2; q2.push(G); while (!q2.empty()){ int v = q2.front(); q2.pop(); for (int i : g[v]){ if (d2[i] == -1){ d2[i] = d2[v] + 1; q2.push(i); } } } for (int i = 0; i < n; i++){ if (p % (d[i] + d2[i]) == 0){ s.insert(i); } } vector D; D.push_back(S); dfs(g, D, S); D.clear(); D.push_back(G); memset(f, 0, sizeof(f)); dfs(g, D, G); if (ans.empty()){ cout << -1 << endl; return 0; } cout << ans.size() << endl; for (int i : ans){ cout << i + 1 << endl; } }