#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; const ll INF=1LL<<60; struct Edge{ int to; ll w; Edge(int to,ll w) : to(to),w(w) {} }; using Graph=vector>; using pli=pair; template bool chmin(T& a,T b){ if(a>b){ a=b; return true; } return false; } Graph G; vector dijkstra(int s){ int n=G.size(); vector dist(n,INF); dist[s]=0; priority_queue,greater> que; que.push({dist[s],s}); while(!que.empty()){ int v=que.top().second; ll d=que.top().first; que.pop(); if(d>dist[v]) continue; for(auto e:G[v]){ if(chmin(dist[e.to],dist[v]+e.w)){ que.push({dist[e.to],e.to}); } } } return dist; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m,p,s,g; cin>>n>>m>>p>>s>>g; s--,g--; G.resize(2*n); rep(i,m){ int u,v; cin>>u>>v; u--,v--; G[u].push_back(Edge(v+n,1)); G[v+n].push_back(Edge(u,1)); G[u+n].push_back(Edge(v,1)); G[v].push_back(Edge(u+n,1)); } vector dis=dijkstra(s); vector dis1=dijkstra(g); vector ANS; if(p%2==0){ rep(i,n){ if(dis[i]+dis1[i]<=p || dis[i+n]+dis1[i+n]<=p) ANS.push_back(i+1); } } else{ rep(i,n){ if(dis[i]+dis1[i+n]<=p || dis[i+n]+dis1[i]<=p) ANS.push_back(i+1); } } int a=ANS.size(); if(a==0) cout<<-1<