#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) templateostream& operator<<(ostream& os,const pair&a){return os<<"("<void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<void chmin(T&a,const T&b){if(a>b)a=b;} templatevoid chmax(T&a,const T&b){if(a g[MAX_N]; void search(int s, int dist[MAX_N][2]) { REP(i, MAX_N) REP(j, 2) dist[i][j] = INF; queue> q; q.push({s, 0}); dist[s][0] = 0; while (!q.empty()) { auto p = q.front(); q.pop(); int u = p.first; int f = p.second; for (int v : g[u]) { if (dist[v][1-f] > dist[u][f] + 1) { dist[v][1-f] = dist[u][f] + 1; q.push({v, 1-f}); } } } } int main2() { REP(i, MAX_N) g[i].clear(); N = nextLong(); int M = nextLong(); int P = nextLong(); int S = nextLong() - 1; int G = nextLong() - 1; REP(i, M) { int a = nextLong() - 1; int b = nextLong() - 1; g[a].push_back(b); g[b].push_back(a); } search(S, fromS); search(G, fromG); // REP(i, N) { cout << fromS[i][0] << " "; } cout << endl; // REP(i, N) { cout << fromS[i][1] << " "; } cout << endl; // REP(i, N) { cout << fromG[i][0] << " "; } cout << endl; // REP(i, N) { cout << fromG[i][1] << " "; } cout << endl; if (fromS[G][P%2] == INF) { cout << -1 << endl; return 0; } vector ans; REP(i, N) { bool ok = false; REP(f1, 2) REP(f2, 2) { int pp = fromS[i][f1] + fromG[i][f2]; if (pp <= P && (P - pp) % 2 == 0) ok = true; } if (ok) ans.push_back(i+1); } cout << ans.size() << endl; REP(i, ans.size()) cout << ans[i] << '\n'; return 0; } int main() { #ifdef LOCAL for (;!cin.eof();cin>>ws) #endif main2(); return 0; }