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 double g = 10.0, eps = 1e-9;
const int N = 1200000 + 10, maxn = 100000 + 10, inf = 0x3f3f3f3f,
          INF = 0x3f3f3f3f3f3f3f3f;
struct qu {
  int t;
  long long l, r;
} q[N];
int lazy[N << 2], value[N << 2];
int cnt;
long long Hash[N << 2];
void pushup(int rt) { value[rt] = value[rt << 1] + value[rt << 1 | 1]; }
void pushdown(int l, int r, int rt) {
  int m = (l + r) >> 1;
  if (lazy[rt] == 1) {
    value[rt << 1] = m - l + 1;
    value[rt << 1 | 1] = r - m;
    lazy[rt << 1] = lazy[rt << 1 | 1] = 1;
  } else if (lazy[rt] == 2) {
    value[rt << 1] = value[rt << 1 | 1] = 0;
    lazy[rt << 1] = lazy[rt << 1 | 1] = 2;
  } else if (lazy[rt] == 3) {
    value[rt << 1] = m - l + 1 - value[rt << 1];
    value[rt << 1 | 1] = r - m - value[rt << 1 | 1];
    lazy[rt << 1] = 3 - lazy[rt << 1];
    lazy[rt << 1 | 1] = 3 - lazy[rt << 1 | 1];
  }
  lazy[rt] = 0;
}
void build(int l, int r, int rt) {
  value[rt] = 0, lazy[rt] = 0;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
}
void update(int L, int R, int op, int l, int r, int rt) {
  if (L <= l && r <= R) {
    if (op == 1) {
      value[rt] = r - l + 1;
      lazy[rt] = op;
    } else if (op == 2) {
      value[rt] = 0;
      lazy[rt] = op;
    } else {
      if (lazy[rt]) pushdown(l, r, rt);
      value[rt] = r - l + 1 - value[rt];
      lazy[rt] = op;
    }
    return;
  }
  pushdown(l, r, rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, op, l, m, rt << 1);
  if (m < R) update(L, R, op, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
int query(int l, int r, int rt) {
  if (l == r) return l;
  pushdown(l, r, rt);
  int m = (l + r) >> 1;
  if (value[rt << 1] == m - l + 1)
    return query(m + 1, r, rt << 1 | 1);
  else
    return query(l, m, rt << 1);
}
void add(long long x) {
  if (x != 0) Hash[cnt++] = x;
}
int main() {
  int n;
  cnt = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%lld%lld", &q[i].t, &q[i].l, &q[i].r);
    add(q[i].l - 1), add(q[i].l), add(q[i].l + 1);
    add(q[i].r - 1), add(q[i].r), add(q[i].r + 1);
  }
  Hash[cnt++] = 1;
  sort(Hash, Hash + cnt);
  cnt = unique(Hash, Hash + cnt) - Hash;
  build(1, cnt, 1);
  for (int i = 0; i < n; i++) {
    int op = q[i].t;
    int tel = lower_bound(Hash, Hash + cnt, q[i].l) - Hash;
    int ter = lower_bound(Hash, Hash + cnt, q[i].r) - Hash;
    update(tel + 1, ter + 1, q[i].t, 1, cnt, 1);
    int ans = query(1, cnt, 1);
    printf("%lld\n", Hash[ans - 1]);
  }
  return 0;
}