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;
int n, m, t[300005 / 3];
long long L[300005 / 3], R[300005 / 3], q[300005];
struct node {
  int l, r, tag, rev;
  long long sum;
} tree[300005 * 4];
void pushsum(int Index) {
  tree[Index].sum = tree[Index * 2].sum + tree[Index * 2 + 1].sum;
}
void build(int l, int r, int Index) {
  tree[Index].l = l;
  tree[Index].r = r;
  tree[Index].rev = tree[Index].sum = 0;
  tree[Index].tag = -1;
  if (l == r) return;
  int mid = (l + r) / 2;
  build(l, mid, Index * 2);
  build(mid + 1, r, Index * 2 + 1);
  pushsum(Index);
}
void pushdown(int Index) {
  if (tree[Index].tag != -1) {
    tree[Index * 2].tag = tree[Index].tag;
    tree[Index * 2].rev = 0;
    tree[Index * 2].sum =
        (tree[Index * 2].r - tree[Index * 2].l + 1) * tree[Index].tag;
    tree[Index * 2 + 1].tag = tree[Index].tag;
    tree[Index * 2 + 1].rev = 0;
    tree[Index * 2 + 1].sum =
        (tree[Index * 2 + 1].r - tree[Index * 2 + 1].l + 1) * tree[Index].tag;
    tree[Index].tag = -1;
  }
  if (tree[Index].rev) {
    if (tree[Index * 2].tag != -1)
      tree[Index * 2].tag ^= 1;
    else
      tree[Index * 2].rev ^= 1;
    if (tree[Index * 2 + 1].tag != -1)
      tree[Index * 2 + 1].tag ^= 1;
    else
      tree[Index * 2 + 1].rev ^= 1;
    tree[Index * 2].sum =
        tree[Index * 2].r - tree[Index * 2].l + 1 - tree[Index * 2].sum;
    tree[Index * 2 + 1].sum = tree[Index * 2 + 1].r - tree[Index * 2 + 1].l +
                              1 - tree[Index * 2 + 1].sum;
    tree[Index].rev = 0;
  }
}
void update(int Index, int t, int l, int r) {
  if (l <= tree[Index].l && tree[Index].r <= r) {
    if (tree[Index].l == tree[Index].r) {
      if (t == 1) tree[Index].sum = 1;
      if (t == 2) tree[Index].sum = 0;
      if (t == 3) tree[Index].sum ^= 1;
    } else {
      if (t == 1) {
        tree[Index].tag = 1;
        tree[Index].rev = 0;
        tree[Index].sum = tree[Index].r - tree[Index].l + 1;
      }
      if (t == 2) {
        tree[Index].tag = 0;
        tree[Index].rev = 0;
        tree[Index].sum = 0;
      }
      if (t == 3) {
        if (tree[Index].tag != -1)
          tree[Index].tag ^= 1;
        else
          tree[Index].rev ^= 1;
        tree[Index].sum = tree[Index].r - tree[Index].l + 1 - tree[Index].sum;
      }
    }
    return;
  }
  pushdown(Index);
  int mid = tree[Index].r + tree[Index].l >> 1;
  if (l <= mid) update(Index * 2, t, l, r);
  if (r > mid) update(Index * 2 + 1, t, l, r);
  pushsum(Index);
}
int query(int Index) {
  if (tree[Index].l == tree[Index].r) return tree[Index].l;
  pushdown(Index);
  if (tree[Index * 2].sum < tree[Index * 2].r - tree[Index * 2].l + 1)
    return query(Index * 2);
  return query(Index * 2 + 1);
}
int main() {
  scanf("%d", &m);
  q[++n] = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d %lld %lld", &t[i], &L[i], &R[i]);
    q[++n] = L[i], q[++n] = R[i], q[++n] = R[i] + 1;
  }
  sort(q + 1, q + n + 1);
  n = unique(q + 1, q + 1 + n) - q - 1;
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    L[i] = lower_bound(q + 1, q + 1 + n, L[i]) - q;
    R[i] = lower_bound(q + 1, q + 1 + n, R[i]) - q;
    update(1, t[i], L[i], R[i]);
    printf("%lld\n", q[query(1)]);
  }
  return 0;
}