#include #include using namespace std; using namespace atcoder; typedef long long int ll; typedef long double ld; typedef vector vi; typedef vector vvi; typedef vector vvvi; typedef vector vvvvi; typedef pair pi; typedef pair ppi; typedef pair pppi; typedef pair ppppi; #define FOR(i,l,r) for(ll i=l;i=l;i--) #define RREP(i,n) RFOR(i,0,n) #define ALL(x) x.begin(),x.end() #define F first #define S second #define BS(A,x) binary_search(ALL(A),x) #define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin()) #define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin()) #define COU(A,x) (UB(A,x)-LB(A,x)) #define sz(c) ((ll)(c).size()) /* #include namespace mp=boost::multiprecision; using Bint=mp::cpp_int; */ templateusing min_priority_queue=priority_queue,greater>; templateostream&operator<<(ostream&os,pair&p){os<istream&operator>>(istream&is,pair&p){is>>p.F>>p.S;return is;} templateostream&operator<<(ostream&os,vector&v){REP(i,sz(v))os<istream&operator>>(istream&is,vector&v){for(T&in:v)is>>in;return is;} templatebool chmax(T&a,T b){if(abool chmin(T&a,T b){if(b vm; typedef vector vvm; typedef vector vvvm; typedef vector vvvvm; ostream&operator<<(ostream&os,mint&a){os<>N>>Q; setS; while(Q--){ ll t;cin>>t; if(t==1){ ll L,R;cin>>L>>R;L--;R--; auto s=S.upper_bound(pi(L,1e18)); if(s!=S.begin()){s--;if((*s).S>=L)L=(*s).F;else s++;} vectorP; while(s!=S.end()&&((*s).F)<=R){ chmax(R,(*s).S); P.emplace_back(*s); s++; } //cout<>L>>R;L--;R--; auto t=S.upper_bound(pi(L,1e18)); if(t!=S.begin()){ t--; if((*t).S>L){ auto p=*t; if(p.S>=R){ S.insert(pi(p.F,L)); S.insert(pi(R,p.S)); S.erase(t); continue; } p.S=L; S.erase(t); S.insert(p); } } t=S.upper_bound(pi(L,1e18)); vectorP; while(t!=S.end()&&(*t).S>u>>v;u--;v--; if(u==v){cout<<1<v)swap(u,v); auto t=S.upper_bound(pi(v,1e18)); if(t==S.begin()){cout<<0<=v&&(*t).F<=u)cout<<1<>v;v--; auto t=S.upper_bound(pi(v,1e18)); if(t==S.begin()){cout<<1<=v)cout<<(*t).S-(*t).F+1<