#include #include #include #include #include #include #include #include #include #include #include #include #define int long long #define double long double #define rep(i,n) for(int i=0;i r; UnionFind(int N){ r=vector(N,-1); } int root(int x){ if(r[x]<0) return x; return r[x]=root(r[x]); } bool unite(int x,int y){ x=root(x); y=root(y); if(x==y) return false; if(r[x]>r[y]) swap(x,y); r[x]+=r[y]; r[y]=x; return true; } int size(int x){ return -r[root(x)]; } }; vector v; int n,m,cnt=0,ans=0,aa[220000],ab[220000]; pair pp[220000]; string s,ss[220000]; queue que; signed main(){ cin>>n>>m; rep(i,m){ cin>>pp[i].first>>pp[i].second; if(abs(pp[i].first-pp[i-1].first)