func_code_string: #include <bits/stdc++.h>   using namespace std;   #pragma optimize( -O3 )   int cnt;   int t[1200005];   int lazy[1200005];   long long int ans[300005];   void push(int v, int tl, int tr) {     int tm = (tl + tr) / 2;     if (lazy[v] == 2) {       t[v * 2] = tm - tl + 1;       t[2 * v + 1] = tr - tm;       lazy[2 * v] = 2;       lazy[2 * v + 1] = 2;       lazy[v] = 0;     } else if (lazy[v] == 3) {       t[2 * v] = 0;       t[2 * v + 1] = 0;       lazy[2 * v] = 3;       lazy[2 * v + 1] = 3;       lazy[v] = 0;     } else if (lazy[v]) {       t[2 * v] = (tm - tl + 1) - t[2 * v];       t[2 * v + 1] = (tr - tm) - t[2 * v + 1];       lazy[2 * v] ^= 1;       lazy[2 * v + 1] ^= 1;       lazy[v] = 0;     }   }   void update(int v, int tl, int tr, int l, int r, int type) {     if (l > r) return;     if (l == tl && tr == r) {       push(v, tl, tr);       if (type == 1) {         t[v] = (tr - tl + 1);         lazy[v] = 2;       } else if (type == 2) {         t[v] = 0;         lazy[v] = 3;       } else if (type == 3) {         t[v] = (tr - tl + 1) - t[v];         lazy[v] ^= 1;       }     } else {       push(v, tl, tr);       int tm = (tl + tr) / 2;       update(v * 2, tl, tm, l, min(r, tm), type);       update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, type);       t[v] = (t[v * 2] + t[v * 2 + 1]);     }   }   int first(int v, int tl, int tr) {     if (tl == tr) {       return tl;     }     int tm = (tl + tr) / 2;     push(v, tl, tr);     if (t[v * 2] != (tm - tl + 1)) {       return first(v * 2, tl, tm);     } else {       return first(v * 2 + 1, tm + 1, tr);     }   }   void solve() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     vector<pair<int, pair<long long int, long long int>>> v;     set<long long int> se;     for (int i = 0; i < n; i++) {       long long int t, l, r;       cin >> t >> l >> r;       v.push_back({t, {l, r}});       se.insert(l);       se.insert(r + 1);     }     se.insert(1);     map<long long int, int> m;     int pt = 0;     for (auto u : se) {       m[u] = pt;       ans[pt] = u;       pt++;     };     for (auto u : v) {       cnt++;       int ti = u.first;       int l = m[u.second.first];       int r = m[u.second.second + 1] - 1;       ;       update(1, 0, 200001, l, r, ti);       int val = first(1, 0, 200001);       cout << ans[val] <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       solve();     }   }   