/** * @FileName a.cpp * @Author kanpurin * @Created 2020.08.25 03:31:17 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; template struct Dijkstra { private: int V; struct edge { int to; T cost; }; vector> G; public: const T inf = numeric_limits::max(); vector d; Dijkstra(int V) : V(V) { G.resize(V); } void add_edge(int from, int to, T weight, bool directed = false) { G[from].push_back({to,weight}); if (!directed) G[to].push_back({from,weight}); } void build(int s) { d.assign(V, inf); typedef tuple P; priority_queue, greater

> pq; d[s] = 0; pq.push(P(d[s], s)); while (!pq.empty()) { P p = pq.top(); pq.pop(); int v = get<1>(p); if (d[v] < get<0>(p)) continue; for (const edge &e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; pq.push(P(d[e.to], e.to)); } } } } }; int main() { int n,m,p;cin >> n >> m >> p; int s,g;cin >> s >> g; s--;g--; Dijkstra G1(n+n),G2(n+n); for (int i = 0; i < m; i++) { int u,v;cin >> u >> v; u--; v--; G1.add_edge(u,n+v,1); G1.add_edge(n+u,v,1); G2.add_edge(u,n+v,1); G2.add_edge(n+u,v,1); } G1.build(s); G2.build(g); vector ans; for (int i = 0; i < n; i++) { if (p & 1) { if ((G1.d[i] != G1.inf && G2.d[i+n] != G2.inf && G1.d[i] + G2.d[i+n] <= p) || (G1.d[i+n] != G1.inf && G2.d[i] != G2.inf && G1.d[i+n] + G2.d[i] <= p)) { ans.push_back(i+1); } } else { if ((G1.d[i] != G1.inf && G2.d[i] != G2.inf && G1.d[i] + G2.d[i] <= p) || (G1.d[i+n] != G1.inf && G2.d[i+n] != G2.inf && G1.d[i+n] + G2.d[i+n] <= p)) { ans.push_back(i+1); } } } if (ans.size() == 0) { puts("-1"); return 0; } cout << ans.size() << endl; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } return 0; }