int n,m,a,b,x,y,l[1d5],r[1d5],c[1d5]; graph g; deque q; { rd(n,m,a,b,(l--,r)(m)); g.setEdge(n+1,m,l,r); rep(i,a){ c[i]=1; q.push_back(i); } while(!q.empty()){ x=q.front(); q.pop_front(); if(x>=b){ wt(c[x]-1); exit(0); } rep[g.edge[x]](y,g.es[x]){ if(!c[y]){ c[y]=c[x]+1; q.push_back(y); } } } wt(-1); }