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;
struct Segment_Tree {
  int l, r, lazy, sum;
} a[1600010];
long long n, m;
long long t[100010], l[100010], r[100010], b[400010], cnt;
long long read() {
  long long f = 1, k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c >= '0' && c <= '9') k = k * 10ll + c - '0', c = getchar();
  return k * f;
}
void build(int cur, int l, int r) {
  a[cur].l = l;
  a[cur].r = r;
  a[cur].lazy = -1;
  if (l == r) return;
  int mid = (a[cur].l + a[cur].r) >> 1;
  build((cur << 1), l, mid);
  build((cur << 1 | 1), mid + 1, r);
}
void pushdown(int cur) {
  if (a[cur].lazy == -1 || a[cur].l == a[cur].r) return;
  if (a[cur].lazy == 0) {
    a[(cur << 1)].sum = a[(cur << 1 | 1)].sum = 0;
    a[(cur << 1)].lazy = a[(cur << 1 | 1)].lazy = 0;
  } else if (a[cur].lazy == 1) {
    a[(cur << 1)].sum = a[(cur << 1)].r - a[(cur << 1)].l + 1;
    a[(cur << 1 | 1)].sum = a[(cur << 1 | 1)].r - a[(cur << 1 | 1)].l + 1;
    a[(cur << 1)].lazy = a[(cur << 1 | 1)].lazy = 1;
  } else {
    if (a[(cur << 1)].lazy == 0 || a[(cur << 1)].lazy == 1) {
      a[(cur << 1)].lazy ^= 1;
      a[(cur << 1)].sum =
          (a[(cur << 1)].r - a[(cur << 1)].l + 1) * a[(cur << 1)].lazy;
    } else {
      a[(cur << 1)].sum =
          a[(cur << 1)].r - a[(cur << 1)].l + 1 - a[(cur << 1)].sum;
      if (a[(cur << 1)].lazy == 2)
        a[(cur << 1)].lazy = -1;
      else
        a[(cur << 1)].lazy = 2;
    }
    if (a[(cur << 1 | 1)].lazy == 0 || a[(cur << 1 | 1)].lazy == 1) {
      a[(cur << 1 | 1)].lazy ^= 1;
      a[(cur << 1 | 1)].sum = (a[(cur << 1 | 1)].r - a[(cur << 1 | 1)].l + 1) *
                              a[(cur << 1 | 1)].lazy;
    } else {
      a[(cur << 1 | 1)].sum =
          a[(cur << 1 | 1)].r - a[(cur << 1 | 1)].l + 1 - a[(cur << 1 | 1)].sum;
      if (a[(cur << 1 | 1)].lazy == 2)
        a[(cur << 1 | 1)].lazy = -1;
      else
        a[(cur << 1 | 1)].lazy = 2;
    }
  }
  a[cur].lazy = -1;
}
void sets(int cur, int l, int r, int v) {
  if (a[cur].l >= l && a[cur].r <= r) {
    a[cur].sum = (a[cur].r - a[cur].l + 1) * v;
    a[cur].lazy = v;
    return;
  }
  pushdown(cur);
  int mid = (a[cur].r + a[cur].l) >> 1;
  if (l <= mid) sets((cur << 1), l, r, v);
  if (r > mid) sets((cur << 1 | 1), l, r, v);
  a[cur].sum = a[(cur << 1)].sum + a[(cur << 1 | 1)].sum;
}
void chan(int cur, int l, int r) {
  if (a[cur].l >= l && a[cur].r <= r) {
    if (a[cur].lazy == 0 || a[cur].lazy == 1) {
      a[cur].lazy ^= 1;
      a[cur].sum = (a[cur].r - a[cur].l + 1) * a[cur].lazy;
    } else {
      a[cur].sum = (a[cur].r - a[cur].l + 1) - a[cur].sum;
      if (a[cur].lazy == 2)
        a[cur].lazy = -1;
      else
        a[cur].lazy = 2;
    }
    return;
  }
  pushdown(cur);
  int mid = (a[cur].l + a[cur].r) >> 1;
  if (l <= mid) chan((cur << 1), l, r);
  if (r > mid) chan((cur << 1 | 1), l, r);
  a[cur].sum = a[(cur << 1)].sum + a[(cur << 1 | 1)].sum;
}
int query(int cur) {
  if (a[cur].sum == 0) return a[cur].l;
  pushdown(cur);
  if (a[(cur << 1)].sum < a[(cur << 1)].r - a[(cur << 1)].l + 1)
    return query((cur << 1));
  else
    return query((cur << 1 | 1));
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    t[i] = read();
    l[i] = read();
    r[i] = read();
    b[++cnt] = l[i];
    if (l[i] > 1ll) b[++cnt] = l[i] - 1ll;
    b[++cnt] = r[i];
    b[++cnt] = r[i] + 1ll;
  }
  b[++cnt] = 1;
  sort(b + 1, b + cnt + 1);
  cnt = unique(b + 1, b + cnt + 1) - b - 1;
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(b + 1, b + cnt + 1, l[i]) - b;
    r[i] = lower_bound(b + 1, b + cnt + 1, r[i]) - b;
  }
  build(1, 1, cnt);
  for (int i = 1; i <= n; i++) {
    if (t[i] == 1)
      sets(1, l[i], r[i], 1);
    else if (t[i] == 2)
      sets(1, l[i], r[i], 0);
    else
      chan(1, l[i], r[i]);
    printf("%lld\n", b[query(1)]);
  }
  return 0;
}