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;
int n;
struct node {
  int op;
  long long l;
  long long r;
} q[N + 5];
int cnt;
long long Hash[3 * N + 5];
int len;
struct T {
  int sum;
  int lazy;
} tree[12 * N + 5];
void pushup(int k) { tree[k].sum = tree[k << 1].sum + tree[k << 1 | 1].sum; }
void pushdown(int k, int l, int r) {
  if (tree[k].lazy == 0) return;
  int mid = (l + r) >> 1;
  if (tree[k].lazy == 1) {
    tree[k << 1].sum = mid - l + 1;
    tree[k << 1 | 1].sum = r - (mid + 1) + 1;
    tree[k << 1].lazy = tree[k << 1 | 1].lazy = tree[k].lazy;
  } else if (tree[k].lazy == 2) {
    tree[k << 1].sum = tree[k << 1 | 1].sum = 0;
    tree[k << 1].lazy = tree[k << 1 | 1].lazy = tree[k].lazy;
  } else {
    tree[k << 1].sum = mid - l + 1 - tree[k << 1].sum;
    tree[k << 1 | 1].sum = r - (mid + 1) + 1 - tree[k << 1 | 1].sum;
    if (tree[k << 1].lazy == 0)
      tree[k << 1].lazy = 3;
    else if (tree[k << 1].lazy == 1)
      tree[k << 1].lazy = 2;
    else if (tree[k << 1].lazy == 2)
      tree[k << 1].lazy = 1;
    else if (tree[k << 1].lazy == 3)
      tree[k << 1].lazy = 0;
    if (tree[k << 1 | 1].lazy == 0)
      tree[k << 1 | 1].lazy = 3;
    else if (tree[k << 1 | 1].lazy == 1)
      tree[k << 1 | 1].lazy = 2;
    else if (tree[k << 1 | 1].lazy == 2)
      tree[k << 1 | 1].lazy = 1;
    else if (tree[k << 1 | 1].lazy == 3)
      tree[k << 1 | 1].lazy = 0;
  }
  tree[k].lazy = 0;
}
void build(int k, int l, int r) {
  if (l == r) {
    tree[k].sum = tree[k].lazy = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  pushup(k);
}
void update(int k, int l, int r, int flag, int x, int y) {
  if (l >= x && r <= y) {
    if (flag == 1) {
      tree[k].sum = r - l + 1;
      tree[k].lazy = 1;
      return;
    } else if (flag == 2) {
      tree[k].sum = 0;
      tree[k].lazy = 2;
      return;
    } else {
      tree[k].sum = (r - l + 1) - tree[k].sum;
      if (tree[k].lazy == 0)
        tree[k].lazy = 3;
      else if (tree[k].lazy == 1)
        tree[k].lazy = 2;
      else if (tree[k].lazy == 2)
        tree[k].lazy = 1;
      else if (tree[k].lazy == 3)
        tree[k].lazy = 0;
      return;
    }
  }
  int mid = (l + r) >> 1;
  pushdown(k, l, r);
  if (x <= mid) update(k << 1, l, mid, flag, x, y);
  if (mid < y) update(k << 1 | 1, mid + 1, r, flag, x, y);
  pushup(k);
}
int query(int k, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) >> 1;
  pushdown(k, l, r);
  if (tree[k << 1].sum < mid - l + 1) return query(k << 1, l, mid);
  return query(k << 1 | 1, mid + 1, r);
}
int main() {
  scanf("%d", &n);
  Hash[++cnt] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld%lld", &q[i].op, &q[i].l, &q[i].r);
    Hash[++cnt] = q[i].l;
    Hash[++cnt] = q[i].r;
    Hash[++cnt] = q[i].r + 1;
  }
  sort(Hash + 1, Hash + cnt + 1);
  len = unique(Hash + 1, Hash + cnt + 1) - (Hash + 1);
  for (int i = 1; i <= n; i++) {
    q[i].l = lower_bound(Hash + 1, Hash + len + 1, q[i].l) - Hash;
    q[i].r = lower_bound(Hash + 1, Hash + len + 1, q[i].r) - Hash;
  }
  build(1, 1, len);
  for (int i = 1; i <= n; i++) {
    update(1, 1, len, q[i].op, q[i].l, q[i].r);
    printf("%lld\n", Hash[query(1, 1, len)]);
  }
  return 0;
}