#include using namespace std; #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define rep(i,n,m) for(int i = (n); i < (int)(m); i++) #define rrep(i,n,m) for(int i = (m) - 1; i >= (int)(n); i--) using ll = long long; using ld = long double; const ll MOD = 1e9+7; //const ll MOD = 998244353; const ll INF = 1e9+1; template bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;} template bool chmax(T &a,T b){if(a vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } vectordist(200001); using P=pair; void bfs(ll k,vector>&g){ queue

q; ll n=g.size(); q.emplace(k,0); fill(dist.begin(),dist.begin()+n,INF); while(!q.empty()){ ll x=q.front().first; ll len=q.front().second; if(dist[x]==INF){ dist[x]=len; for(ll i=0;i>n>>m>>a>>b; a--;b--; vector>g(n+1); rep(i,0,m){ int l,r; cin>>l>>r; l--; chmax(l,a); chmax(r,a); chmin(l,b+1); chmin(r,b+1); g[l].push_back(r); g[r].push_back(l); } bfs(a,g); if(dist[b+1]!=INF)cout<