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;
using lint = long long;
struct query {
  int t;
  lint l, r;
};
query qs[111111];
struct SegmentTree {
  int* a;
  int* st;
  bool* ni;
  int n;
  SegmentTree(int n) : n(n) {
    a = new int[4 * n];
    st = new int[4 * n];
    ni = new bool[4 * n];
    fill(a, a + 4 * n, 0);
    fill(st, st + 4 * n, -1);
    fill(ni, ni + 4 * n, false);
  }
  void push(int i, int l, int r) {
    if (st[i] != -1) {
      a[i] = (r - l) * st[i];
      if (l + 1 != r) {
        st[i * 2 + 1] = st[i];
        ni[i * 2 + 1] = false;
        st[i * 2 + 2] = st[i];
        ni[i * 2 + 2] = false;
      }
      st[i] = -1;
    }
    if (ni[i]) {
      a[i] = r - l - a[i];
      if (l + 1 != r) {
        ni[i * 2 + 1] ^= true;
        ni[i * 2 + 2] ^= true;
      }
      ni[i] = false;
    }
  }
  void set(int i, int l, int r, int ql, int qr, int x, bool inv) {
    push(i, l, r);
    if (r <= ql || qr <= l) {
      return;
    }
    if (ql <= l && r <= qr) {
      st[i] = x;
      ni[i] = inv;
      push(i, l, r);
      return;
    }
    int m = (l + r) >> 1;
    set(i * 2 + 1, l, m, ql, qr, x, inv);
    set(i * 2 + 2, m, r, ql, qr, x, inv);
    a[i] = a[i * 2 + 1] + a[i * 2 + 2];
  }
  int lz(int i, int l, int r) {
    push(i, l, r);
    if (a[i] == r - l) {
      return -1;
    }
    if (a[i] == 0) {
      return l;
    }
    int m = (l + r) >> 1;
    int res = lz(i * 2 + 1, l, m);
    if (res == -1) {
      res = lz(i * 2 + 2, m, r);
    }
    return res;
  }
};
void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<lint> xs;
  for (int i = (0); i < int(n); ++i) {
    cin >> qs[i].t >> qs[i].l >> qs[i].r;
    xs.push_back(qs[i].l - 1);
    xs.push_back(qs[i].r);
  }
  xs.push_back(0);
  sort(xs.begin(), xs.end());
  xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
  SegmentTree st(xs.size() + 3);
  for (int i = (0); i < int(n); ++i) {
    query q = qs[i];
    q.l = lower_bound(xs.begin(), xs.end(), q.l - 1) - xs.begin();
    q.r = lower_bound(xs.begin(), xs.end(), q.r) - xs.begin();
    if (q.t == 1) {
      st.set(0, 0, st.n, q.l, q.r, 1, false);
    } else if (q.t == 2) {
      st.set(0, 0, st.n, q.l, q.r, 0, false);
    } else {
      st.set(0, 0, st.n, q.l, q.r, -1, true);
    }
    cout << xs[st.lz(0, 0, st.n)] + 1 << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve(cin, cout);
  return 0;
}