#include #define rep(i,n) for (int i = 0; i < (int)(n); i ++) #define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i) using namespace std; using ll = long long; using PL = pair; using P = pair; constexpr int INF = 1000000000; constexpr long long HINF = 1000000000000000; constexpr long long MOD = 1000000007;// = 998244353; constexpr double EPS = 1e-4; constexpr double PI = 3.14159265358979; int N; vector bfs(vector> &G,int s) { vector dist(2*N,-1); dist[s] = 0; queue q; q.push(s); while (!q.empty()) { int v = q.front(); q.pop(); for (int e:G[v]) { if (dist[e] >= 0) continue; dist[e] = dist[v] + 1; q.push(e); } } return dist; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int M,P,s,g; cin >> N >> M >> P >> s >> g; --s; --g; vector> G(2*N); rep(i,M) { int a,b; cin >> a >> b; --a; --b; G[a].push_back(b + N); G[b + N].push_back(a); G[b].push_back(a + N); G[a + N].push_back(b); } vector dist1 = bfs(G,s); vector dist2 = bfs(G,g); vector ans; auto judge = [&](int a,int b) { return (dist1[a] >= 0 && dist2[b] >= 0 && dist1[a] + dist2[b] <= P); }; rep(i,N) { if (i == s || i == g) { if (P%2 == 0 && dist1[g] >= 0 && dist1[g] <= P) { ans.push_back(i + 1); } if (P%2 == 1 && dist1[g + N] >= 0 && dist1[g + N] <= P) { ans.push_back(i + 1); } continue; } bool flag = false; if (P%2 == 0) { if (judge(i,i) || judge(i + N,i + N)) flag = true; } else { if (judge(i,i + N) || judge(i + N,i)) flag = true; } if (flag) ans.push_back(i + 1); } if ((int)ans.size() == 0) { cout << -1 << '\n'; return 0; } cout << ans.size() << '\n'; rep(i,ans.size()) cout << ans[i] << '\n'; return 0; }