#pragma GCC target("avx2,avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include using namespace std; using namespace __gnu_pbds; using ll = long long; using ull = unsigned long long; using pii = pair; using pll = pair; #define rep(i, n) for(int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() constexpr char ln = '\n'; constexpr long long MOD = 1000000007; //constexpr long long MOD = 998244353; template inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;} template inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;} inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);} inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);} inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);} inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);} inline int popcount(int x) {return __builtin_popcount(x);} inline int popcount(long long x) {return __builtin_popcountll(x);} void print() {cout << "\n";} template void print(const T &x, const Args &... args) { cout << x << " "; print(args...); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// vector bfs(const vector> &G, int s) { vector ret(G.size(),-1); ret[s] = 0; queue que; que.emplace(s); while (!que.empty()) { int v = que.front(); que.pop(); for (auto nv : G[v]) { if (ret[nv] != -1) continue; ret[nv] = ret[v] + 1; que.emplace(nv); } } return ret; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,P; cin >> N >> M >> P; int s,g; cin >> s >> g; --s; --g; vector> G(N); rep(i,M) { int u,v; cin >> u >> v; --u; --v; G[u].emplace_back(v); G[v].emplace_back(u); } auto dist_s = bfs(G,s); if (dist_s[g] > P or ((dist_s[g]^P)&1)) { cout << -1 << ln; return 0; } auto dist_g = bfs(G,g); vector ans; rep(i,N) { if (dist_s[i]+dist_g[i]<=P) ans.emplace_back(i+1); } cout << ans.size() << ln; for (auto i : ans) cout << i << ln; }