#include #define endl '\n' using namespace std; const int maxN = 1e5 + 5; struct p { int node, time; p(){} p(int node, int time) { this->node = node; this->time = time; } }; bool vis[maxN]; int n, m, a, b, x, y; vector v[maxN]; queue

q; int bfs(int beg, int en) { int currNode, time; q.push(p(beg, 1)); vis[beg] = true; bool k = false; while(!q.empty()) { currNode = q.front().node; time = q.front().time; q.pop(); if(currNode == en) { k = true; break; } for(int i = 0; i < v[currNode].size(); i++) { if(!vis[v[currNode][i]]) { q.push(p(v[currNode][i], time + 1)); vis[v[currNode][i]] = true; } } } if(!k) return -1; return time; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("cities.in", "r", stdin); freopen("cities.out", "w", stdout); cin>>n>>m>>a>>b; for(int i = 0; i < m; i++) { cin>>x>>y; v[x].push_back(y); v[y].push_back(x); } cout<