#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001LL using P = pair; P op(P a,P b){ if(a.first != b.first)return min(a,b); else return {a.first,a.second+b.second}; } P e(){ return {Inf32,0}; } P mapping(int b,P a){ return {a.first+b,a.second}; } int composition(int a,int b){ return a+b; } int id(){ return 0; } int main(){ int N,Q; cin>>N>>Q; vector

a(N-1,{0,1}); lazy_segtree seg(a); vector t(Q),l(Q),r(Q); rep(i,Q){ cin>>t[i]; if(t[i]==1){ cin>>l[i]>>r[i]; l[i]--; if(l[i]!=r[i])seg.apply(l[i],r[i]-1,1); } else if(t[i]==2){ cin>>l[i]; l[i]--; int ii = l[i]; if(l[ii]!=r[ii])seg.apply(l[ii],r[ii]-1,-1); } else{ auto res = seg.all_prod(); int ans = 1; if(res.first == 0)ans += res.second; cout<