#include using namespace std; #include using namespace atcoder; using mint = modint998244353; //多倍長整数// //#include //namespace mp = boost::multiprecision; //using bint = mp::cpp_int; const int INF = 1e9; const int MOD = 998244353; const long long LINF = 4e18; using ll = long long; using vi = vector; using vl = vector; using vs = vector; using vc = vector; using vb = vector; using vvi = vector>; using vvvi = vector>>; using vvvvi = vector>>>; using vvl = vector>; using vvvl = vector>>; using vvvvl = vector>>>; using vvc = vector>; using vvb = vector>; using vvvb = vector>>; using vvvvb = vector>>>; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define dump(x) cout << #x << " = " << (x) << endl; #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(obj) (obj).begin(),(obj).end() struct dat{ int mn; int cnt; }; dat op(dat a, dat b){ if(a.mn == b.mn) return {a.mn, a.cnt + b.cnt}; else if(a.mn < b.mn) return a; else return b; } dat e(){ return {INF, 0}; } dat mp(int f, dat x){ return {x.mn + f, x.cnt}; } int cp(int f,int g){return f + g;} int id(){return 0;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,q; cin >> n >> q; dat init; init = {0, 1}; lazy_segtree seg(vector(n, init)); vi l(q), r(q); rep(i, q){ int t; cin >> t; // rep(i,n) cout << seg.get(i).mn << ' '; // cout << endl; if(t == 1){ cin >> l[i] >> r[i]; l[i]--, r[i]--; seg.apply(l[i], r[i], 1); }else if(t == 2){ int j; cin >> j; j--; seg.apply(l[j], r[j], -1); }else{ dat ret = seg.all_prod(); if(ret.mn == 0) cout << ret.cnt << '\n'; else cout << 1 << '\n'; } } return 0; }