#include #include using namespace std; int N,Q; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>Q; mapS; for(;Q--;) { int op;cin>>op; if(op==1) { int L,R;cin>>L>>R; auto it=S.lower_bound(L); if(it!=S.begin()) { it--; if(it->second>=L) { L=it->first; R=max(R,it->second); it=S.erase(it); } else it++; } while(it!=S.end()&&it->first<=R) { R=max(R,it->second); it=S.erase(it); } S.insert(it,make_pair(L,R)); } else if(op==2) { int L,R;cin>>L>>R; auto it=S.lower_bound(L); if(it!=S.begin()) { it--; if(it->second>R) { pairp=*it; it=S.erase(it); it=S.insert(it,make_pair(p.first,L)); it++; S.insert(it,make_pair(R,p.second)); continue; } if(it->second>L) { pairp=*it; it=S.erase(it); p.second=L; it=S.insert(it,p); it++; } else it++; } while(it!=S.end()&&it->first<=R) { pairp=*it; it=S.erase(it); p.first=R; if(p.first>u>>v; if(u>v)swap(u,v); if(u==v) { cout<<"1\n"; continue; } auto it=S.upper_bound(u); if(it!=S.begin()) { it--; if(it->second>=v)cout<<"1\n"; else cout<<"0\n"; } else cout<<"0\n"; } else { int u;cin>>u; auto it=S.upper_bound(u); int ans=1; if(it!=S.begin()) { it--; if(it->second>=u) { ans=it->second-it->first+1; } } cout<