Problem: You are given a set of integer numbers, initially it is empty. You should perform n queries.

There are three different types of queries: 

  * 1 l r — Add all missing numbers from the interval [l, r]
  * 2 l r — Remove all present numbers from the interval [l, r]
  * 3 l r — Invert the interval [l, r] — add all missing and remove all present numbers from the interval [l, r]



After each query you should output MEX of the set — the smallest positive (MEX ≥ 1) integer number which is not presented in the set.

Input

The first line contains one integer number n (1 ≤ n ≤ 105).

Next n lines contain three integer numbers t, l, r (1 ≤ t ≤ 3, 1 ≤ l ≤ r ≤ 1018) — type of the query, left and right bounds.

Output

Print MEX of the set after each query.

Examples

Input

3
1 3 4
3 1 6
2 1 3


Output

1
3
1


Input

4
1 1 3
3 5 6
2 4 4
3 1 6


Output

4
4
4
1

Note

Here are contents of the set after each query in the first example:

  1. {3, 4} — the interval [3, 4] is added 
  2. {1, 2, 5, 6} — numbers {3, 4} from the interval [1, 6] got deleted and all the others are added 
  3. {5, 6} — numbers {1, 2} got deleted 

Solution (in CPP):

Solution:
#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();
  }
}