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;
const int N = 1e6;
int tree[N + 100], lazy[N + 100], toggle[N + 100];
vector<long long> ele;
vector<pair<pair<long long, long long>, int> > Q;
int now = 0;
void push(int v, int tl, int tr) {
  int tm = (tl + tr) / 2;
  if (lazy[v] == -1) {
    if (toggle[v]) {
      tree[v * 2] = tm - tl + 1 - tree[v * 2];
      tree[v * 2 + 1] = tr - tm - tree[v * 2 + 1];
      toggle[v * 2] ^= 1;
      toggle[v * 2 + 1] ^= 1;
    }
  } else {
    lazy[v] ^= toggle[v];
    if (lazy[v]) {
      tree[v * 2] = tm - tl + 1;
      tree[v * 2 + 1] = tr - tm;
    } else {
      tree[v * 2] = tree[v * 2 + 1] = 0;
    }
    lazy[v * 2] = lazy[v * 2 + 1] = lazy[v];
    toggle[v * 2] = toggle[v * 2 + 1] = 0;
  }
  toggle[v] = 0;
  lazy[v] = -1;
}
void update(int v, int tl, int tr, int l, int r, int val) {
  if (l > r) return;
  if (tl == l && tr == r) {
    if (val == 1) {
      tree[v] = tr - tl + 1;
      lazy[v] = 1;
      toggle[v] = 0;
    } else if (val == 2) {
      tree[v] = 0;
      lazy[v] = 0;
      toggle[v] = 0;
    } else {
      tree[v] = tr - tl + 1 - tree[v];
      toggle[v] ^= 1;
    }
    return;
  }
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  update(v * 2, tl, tm, l, min(r, tm), val);
  update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
  tree[v] = tree[v * 2] + tree[v * 2 + 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long l, r;
    int k;
    cin >> k >> l >> r;
    ele.push_back(l);
    ele.push_back(r + 1);
    Q.push_back(make_pair(make_pair(l, r), k));
  }
  ele.push_back(1);
  ele.push_back(1e18 + 1);
  sort(ele.begin(), ele.end());
  n = unique(ele.begin(), ele.end()) - ele.begin();
  for (auto it : Q) {
    now++;
    int l =
        lower_bound(ele.begin(), ele.begin() + n, it.first.first) - ele.begin();
    int r = lower_bound(ele.begin(), ele.begin() + n, it.first.second + 1) -
            ele.begin();
    update(1, 1, n, l + 1, r, it.second);
    int v = 1, tl = 1, tr = n;
    while (1) {
      if (tl == tr) {
        cout << ele[tl - 1] << "\n";
        break;
      }
      push(v, tl, tr);
      int tm = (tl + tr) / 2;
      if (tree[v * 2] < tm - tl + 1) {
        v = v * 2;
        tr = tm;
      } else {
        v = v * 2 + 1;
        tl = tm + 1;
      }
    }
  }
}