#include using namespace std; using ll=long long; using ld=long double; using P=pair; #define ALL(a) a.begin(),a.end() #define rep(i,l,r) for(ll i=l;i using namespace atcoder; using mint=modint998244353; //using mint=modint1000000007; template void chmax(T& a,const U& b){a=max(a,b);} template void chmin(T& a,const U& b){a=min(a,b);} void printd(ld x){cout<1) { ll wj=(ac+wa)/2; if(wj<=x/wj) ac=wj; else wa=wj; } return ac; } ll ipow(ll x,ll n) { ll res=1; while(n) { if(n&1) res*=x; x*=x; n>>=1; } return res; } ll modulo(ll a,ll b){return ((a%b)+b)%b;} struct interval_set { set

st; ll len=0; ll mx=0; void add(ll l,ll r) { if(l>=r) return; auto it=st.lower_bound({l,-inf}); if(it!=st.begin()) { it--; if(it->secondfirst<=r) { auto [x,y]=*it; chmin(l,x); chmax(r,y); len-=y-x; it=st.erase(it); } st.insert({l,r}); len+=r-l; chmax(mx,r-l); } void del(ll l,ll r) { if(l>=r) return; auto it=st.lower_bound({l,-inf}); if(it!=st.begin()) { it--; if(it->second<=l) it++; } while(it!=st.end()&&it->first>n>>q; interval_set is; rep(_,0,q) { ll l,r; cin>>l>>r; r++; is.add(l,r); cout<