#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair pint; typedef pair pli; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int main(){ ll d,q; cin>>d>>q; set> st; st.insert({longinf,longinf}); st.insert({-longinf,-longinf}); ll ret=0; while(q--){ ll x,y; cin>>x>>y; ++y; auto itr=st.lower_bound({x,0}); --itr; if(itr->second>=x){ x=itr->first; y=max(itr->second,y); itr=st.erase(itr); } else itr++; ll res=y; while(itr->first<=y) { res=max(res,itr->second); itr=st.erase(itr); } st.insert({x,res}); ret=max(res-x,ret); cout<