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 mod = 1e9 + 7;
struct Query {
  int op, l, r;
  long long ql, qr;
} q[100010];
long long a[100010 << 2];
int cnt;
struct SegmentTree {
  int l, r;
  long long val, tag;
} t[100010 << 4];
void pushup(int root) { t[root].val = t[root << 1].val + t[root << 1 | 1].val; }
void pushdown(int root) {
  if (t[root].tag < 0) return;
  int mid = t[root].l + t[root].r >> 1;
  if (t[root].tag < 2) {
    t[root << 1].val = t[root].tag * (mid - t[root].l + 1);
    t[root << 1 | 1].val = t[root].tag * (t[root].r - mid);
    t[root << 1].tag = t[root << 1 | 1].tag = t[root].tag;
  } else {
    t[root << 1].val = mid - t[root].l + 1 - t[root << 1].val;
    t[root << 1 | 1].val = t[root].r - mid - t[root << 1 | 1].val;
    t[root << 1].tag = 1 - t[root << 1].tag;
    t[root << 1 | 1].tag = 1 - t[root << 1 | 1].tag;
  }
  t[root].tag = -1;
}
void build(int l, int r, int root) {
  t[root].l = l;
  t[root].r = r;
  t[root].tag = -1;
  if (l == r) {
    t[root].val = 0;
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, root << 1);
  build(mid + 1, r, root << 1 | 1);
  pushup(root);
}
void update(int op, int l, int r, int root) {
  if (l <= t[root].l && t[root].r <= r) {
    if (op < 2) {
      t[root].val = (1 - op) * (t[root].r - t[root].l + 1);
      t[root].tag = 1 - op;
    } else {
      t[root].val = t[root].r - t[root].l + 1 - t[root].val;
      t[root].tag = 1 - t[root].tag;
    }
    return;
  }
  pushdown(root);
  int mid = t[root].l + t[root].r >> 1;
  if (l <= mid) update(op, l, r, root << 1);
  if (r > mid) update(op, l, r, root << 1 | 1);
  pushup(root);
}
int query(int root) {
  if (t[root].l == t[root].r) return t[root].l;
  pushdown(root);
  int mid = t[root].l + t[root].r >> 1;
  if (t[root << 1].val < mid - t[root].l + 1) return query(root << 1);
  return query(root << 1 | 1);
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    cnt = 0;
    a[++cnt] = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d%I64d%I64d", &q[i].op, &q[i].ql, &q[i].qr);
      a[++cnt] = q[i].ql;
      a[++cnt] = q[i].qr;
      a[++cnt] = q[i].qr + 1;
    }
    sort(a + 1, a + cnt + 1);
    cnt = unique(a + 1, a + cnt + 1) - (a + 1);
    build(1, cnt, 1);
    for (int i = 1; i <= n; i++) {
      q[i].l = lower_bound(a + 1, a + cnt + 1, q[i].ql) - a;
      q[i].r = lower_bound(a + 1, a + cnt + 1, q[i].qr) - a;
      update(q[i].op - 1, q[i].l, q[i].r, 1);
      printf("%I64d\n", a[query(1)]);
    }
  }
  return 0;
}