#include #include #include using namespace std; const long long INF = 1LL << 40; vector getDist(const vector>& g, int start){ queue qu; qu.emplace(start); vector dist(g.size(), INF); dist[start] = 0; while(!qu.empty()){ int p = qu.front(); qu.pop(); for(auto& t : g[p]){ if(dist[t] <= dist[p]+1) continue; dist[t] = dist[p] + 1; qu.push(t); } } return dist; } int main(){ int N, M, P; while(cin >> N >> M >> P){ int S, G; cin >> S >> G; --S; --G; vector> g(2*N); for(int i=0;i> u >> v; --u; --v; g[u].push_back(N+v); g[v].push_back(N+u); g[N+u].push_back(v); g[N+v].push_back(u); } auto s = getDist(g, S); auto e = getDist(g, G); vector res; for(int i=0;i