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 maxn = 8e5 + 5;
int n, tot, m, pos[maxn];
long long b[maxn], rk[maxn];
struct Data {
  int opt;
  long long l, r;
} a[maxn];
struct Node {
  int sum, lazy, tag;
} tree[maxn << 2];
void pushdown(int rt, int l, int r) {
  int mid = l + r >> 1;
  if (tree[rt].lazy) {
    tree[rt << 1].lazy = tree[rt << 1 | 1].lazy = tree[rt].lazy;
    if (~tree[rt].lazy) {
      tree[rt << 1].sum = mid - l + 1;
      tree[rt << 1 | 1].sum = r - mid;
    } else
      tree[rt << 1].sum = tree[rt << 1 | 1].sum = 0;
    tree[rt << 1].tag = tree[rt << 1 | 1].tag = 0;
    tree[rt].lazy = 0;
  }
  if (tree[rt].tag) {
    tree[rt << 1].sum = mid - l + 1 - tree[rt << 1].sum;
    tree[rt << 1 | 1].sum = r - mid - tree[rt << 1 | 1].sum;
    if (tree[rt << 1].lazy)
      tree[rt << 1].lazy = -tree[rt << 1].lazy;
    else
      tree[rt << 1].tag ^= 1;
    if (tree[rt << 1 | 1].lazy)
      tree[rt << 1 | 1].lazy = -tree[rt << 1 | 1].lazy;
    else
      tree[rt << 1 | 1].tag ^= 1;
    tree[rt].tag = 0;
  }
}
void pushup(int rt) {
  tree[rt].sum = tree[rt << 1].sum + tree[rt << 1 | 1].sum;
}
void update1(int rt, int l, int r, int L, int R, int x) {
  if (L <= l && R >= r) {
    if (~x)
      tree[rt].lazy = 1, tree[rt].sum = r - l + 1;
    else
      tree[rt].lazy = -1, tree[rt].sum = 0;
    tree[rt].tag = 0;
    return;
  }
  pushdown(rt, l, r);
  int mid = l + r >> 1;
  if (L <= mid) update1(rt << 1, l, mid, L, R, x);
  if (R > mid) update1(rt << 1 | 1, mid + 1, r, L, R, x);
  pushup(rt);
}
void update2(int rt, int l, int r, int L, int R) {
  if (L <= l && R >= r) {
    if (tree[rt].lazy)
      tree[rt].lazy = -tree[rt].lazy;
    else
      tree[rt].tag ^= 1;
    tree[rt].sum = r - l + 1 - tree[rt].sum;
    return;
  }
  pushdown(rt, l, r);
  int mid = l + r >> 1;
  if (L <= mid) update2(rt << 1, l, mid, L, R);
  if (R > mid) update2(rt << 1 | 1, mid + 1, r, L, R);
  pushup(rt);
}
int query(int rt, int l, int r) {
  if (l == r) return l;
  pushdown(rt, l, r);
  int mid = l + r >> 1, res = 0;
  if (tree[rt << 1].sum != mid - l + 1)
    res = query(rt << 1, l, mid);
  else
    res = query(rt << 1 | 1, mid + 1, r);
  pushup(rt);
  return res;
}
int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%d%lld%lld", &a[i].opt, &a[i].l, &a[i].r), b[++tot] = a[i].l,
                                                      b[++tot] = a[i].r;
  sort(b + 1, b + 1 + tot), m = unique(b + 1, b + 1 + tot) - b - 1;
  for (register int i = 1; i <= m; ++i) {
    pos[i] = pos[i - 1] + 1;
    if (b[i] != b[i - 1] + 1) pos[i]++;
    rk[pos[i]] = b[i];
  }
  for (register int i = 1; i <= n; ++i) {
    a[i].l = pos[lower_bound(b + 1, b + 1 + m, a[i].l) - b];
    a[i].r = pos[lower_bound(b + 1, b + 1 + m, a[i].r) - b];
  }
  for (register int i = 1; i <= n; ++i) {
    if (a[i].opt == 1)
      update1(1, 1, pos[m], a[i].l, a[i].r, 1);
    else if (a[i].opt == 2)
      update1(1, 1, pos[m], a[i].l, a[i].r, -1);
    else
      update2(1, 1, pos[m], a[i].l, a[i].r);
    if (pos[m] == tree[1].sum)
      printf("%lld\n", b[m] + 1);
    else {
      register int temp = query(1, 1, pos[m]);
      if (rk[temp])
        printf("%lld\n", rk[temp]);
      else
        printf("%lld\n", rk[temp - 1] + 1);
    }
  }
  return 0;
}