#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 using P = pair; P op(P a,P b){ a.first += b.first; a.second += b.second; return a; } P e(){ return make_pair(0,0); } P mapping(int a,P b){ if(a==-1)return b; b.first = a * b.second; return b; } int composition(int a,int b){ if(a==-1)return b; return a; } int id(){ return -1; } bool check(P a){ return a.first==a.second; } int main(){ int n,q; cin>>n>>q; vector t(q),a(q),b(q); vector v; rep(i,q){ cin>>t[i]; if(t[i]!=4){ cin>>a[i]>>b[i]; v.push_back(a[i]); v.push_back(b[i]); } else{ cin>>a[i]; v.push_back(a[i]); } } sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); lazy_segtree seg(v.size()-1); rep(i,v.size()-1)seg.set(i,make_pair(0,v[i+1] - v[i])); rep(i,q){ if(t[i]<=2){ int l = distance(v.begin(),lower_bound(v.begin(),v.end(),a[i])); int r = distance(v.begin(),lower_bound(v.begin(),v.end(),b[i])); if(t[i]==1)seg.apply(l,r,1); else seg.apply(l,r,0); } if(t[i]==3){ if(a[i]>b[i])swap(a[i],b[i]); int l = distance(v.begin(),lower_bound(v.begin(),v.end(),a[i])); int r = distance(v.begin(),lower_bound(v.begin(),v.end(),b[i])); if(seg.prod(l,r).first==r-l)cout<<1<(l); l = seg.min_left(r); cout<