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 = 1e5 + 5;
int q, n;
long long qry[N][3], x[N * 4];
int tree[N * 16], lazy[N * 16];
void mrg(int p, int v) {
  if (!lazy[p]) {
    lazy[p] = v;
    return;
  }
  if (v == 3) {
    lazy[p] = 3 - lazy[p];
    return;
  }
  lazy[p] = v;
}
void pushdown(int nd, int l, int r) {
  if (!lazy[nd]) return;
  if (l != r) {
    mrg(nd * 2, lazy[nd]);
    mrg(nd * 2 + 1, lazy[nd]);
  }
  if (lazy[nd] == 1) tree[nd] = r - l + 1;
  if (lazy[nd] == 2) tree[nd] = 0;
  if (lazy[nd] == 3) tree[nd] = r - l + 1 - tree[nd];
  lazy[nd] = 0;
}
void update(int nd, int l, int r, int s, int e, int v) {
  pushdown(nd, l, r);
  if (r < s || e < l) return;
  if (s <= l && r <= e) {
    lazy[nd] = v;
    pushdown(nd, l, r);
    return;
  }
  int m = (l + r) / 2;
  update(nd * 2, l, m, s, e, v);
  update(nd * 2 + 1, m + 1, r, s, e, v);
  tree[nd] = tree[nd * 2] + tree[nd * 2 + 1];
}
long long query(int nd, int l, int r) {
  pushdown(nd, l, r);
  if (l == r) return x[l];
  int m = (l + r) / 2;
  pushdown(nd * 2, l, m);
  pushdown(nd * 2 + 1, m + 1, r);
  if (tree[nd * 2] == m - l + 1)
    return query(nd * 2 + 1, m + 1, r);
  else
    return query(nd * 2, l, m);
}
int xto(long long v) { return lower_bound(x + 1, x + 1 + n, v) - x; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  x[++n] = 1;
  for (int i = 1; i <= q; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    qry[i][0] = a;
    qry[i][1] = b;
    qry[i][2] = c;
    x[++n] = b;
    x[++n] = b + 1;
    x[++n] = c;
    x[++n] = c + 1;
  }
  sort(x + 1, x + 1 + n);
  n = unique(x + 1, x + 1 + n) - x - 1;
  for (int i = 1; i <= q; i++) {
    long long a, b, c;
    a = qry[i][0];
    b = qry[i][1];
    c = qry[i][2];
    b = xto(b);
    c = xto(c);
    update(1, 1, n, b, c, a);
    cout << query(1, 1, n) << "\n";
  }
  return 0;
}