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;
struct seg {
  long long val, lazy;
  seg *l, *r;
  seg() {
    val = lazy = 0;
    l = r = NULL;
  }
};
void upd(seg*& nd, long long l, long long r, long long ty) {
  if (nd == NULL) nd = new seg;
  if (ty == 0) return;
  if (ty == 1)
    nd->val = (r - l + 1), nd->lazy = 1;
  else if (ty == 2)
    nd->val = 0, nd->lazy = 2;
  else {
    if (nd->lazy == 0)
      nd->val = (r - l + 1) - nd->val, nd->lazy = 3;
    else if (nd->lazy == 1)
      nd->val = 0, nd->lazy = 2;
    else if (nd->lazy == 2)
      nd->val = (r - l + 1), nd->lazy = 1;
    else
      nd->val = (r - l + 1) - nd->val, nd->lazy = 0;
  }
}
void prop(seg*& nd, long long l, long long r) {
  long long mid = (l + r) / 2;
  upd(nd->l, l, mid, nd->lazy);
  upd(nd->r, mid + 1, r, nd->lazy);
  nd->lazy = 0;
}
seg* root;
void update(seg*& cur, long long a, long long b, long long ty, long long l,
            long long r) {
  if (a <= l && r <= b) {
    upd(cur, l, r, ty);
    return;
  }
  prop(cur, l, r);
  long long mid = (l + r) / 2;
  if (b <= mid)
    update(cur->l, a, b, ty, l, mid);
  else if (a > mid)
    update(cur->r, a, b, ty, mid + 1, r);
  else {
    update(cur->r, a, b, ty, mid + 1, r);
    update(cur->l, a, b, ty, l, mid);
  }
  cur->val = cur->l->val + cur->r->val;
}
long long query(seg*& cur, long long l, long long r) {
  if (l == r || cur->val == 0) return l;
  prop(cur, l, r);
  long long mid = (l + r) / 2;
  if (cur->l->val == (mid - l + 1))
    return query(cur->r, mid + 1, r);
  else
    return query(cur->l, l, mid);
}
long long n;
vector<pair<long long, pair<long long, long long> > > q;
map<long long, long long> mm, rmap;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  root = new seg;
  mm[1] = 1;
  for (long long i = 1; i <= n; ++i) {
    long long ty, l, r;
    cin >> ty >> l >> r;
    q.push_back(make_pair(ty, make_pair(l, r)));
    mm[l] = 1;
    mm[r + 1] = 1;
  }
  long long cnt = 0;
  for (auto it = mm.begin(); it != mm.end(); it++) {
    mm[it->first] = ++cnt;
    rmap[cnt] = it->first;
  }
  for (auto pp : q) {
    long long ty = pp.first, l = mm[pp.second.first],
              r = mm[pp.second.second + 1] - 1;
    update(root, l, r, ty, 1, cnt);
    cout << rmap[query(root, 1, cnt)] << "\n";
  }
}