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>
struct border {
  long long x;
  int d;
  bool s;
  bool operator<(const border &b) const { return x < b.x; }
} b[100005 << 1];
struct seg {
  int l, r, v, z;
} t[100005 << 3];
long long o[100005 << 1];
int q[3][100005], n;
void build(int k, int l, int r) {
  t[k] = (seg){l, r, 0, -1};
  if (l + 1 < r) {
    int m = (l + r) >> 1;
    build(((k) << 1), l, m);
    build(((k) << 1 | 1), m, r);
  }
}
void push(int k) {
  if (!~t[k].z) return;
  if (t[k].l + 1 < t[k].r) {
    t[((k) << 1)].v = t[k].z ? t[((k) << 1)].r - t[((k) << 1)].l : 0;
    t[((k) << 1)].z = t[k].z;
    t[((k) << 1 | 1)].v =
        t[k].z ? t[((k) << 1 | 1)].r - t[((k) << 1 | 1)].l : 0;
    t[((k) << 1 | 1)].z = t[k].z;
  }
  t[k].z = -1;
}
void set(int k, int l, int r, bool v) {
  if (l >= r) return;
  if (l <= t[k].l && r >= t[k].r) {
    t[k].v = v ? t[k].r - t[k].l : 0;
    t[k].z = v;
  } else {
    push(k);
    int m = (t[k].l + t[k].r) >> 1;
    if (l < m) set(((k) << 1), l, r, v);
    if (r > m) set(((k) << 1 | 1), l, r, v);
    t[k].v = t[((k) << 1)].v + t[((k) << 1 | 1)].v;
  }
}
int sum(int k, int l, int r) {
  if (l >= r) return 0;
  if (l <= t[k].l && r >= t[k].r) return t[k].v;
  push(k);
  int m = (t[k].l + t[k].r) >> 1;
  if (r <= m)
    return sum(((k) << 1), l, r);
  else if (l >= m)
    return sum(((k) << 1 | 1), l, r);
  else
    return sum(((k) << 1), l, r) + sum(((k) << 1 | 1), l, r);
}
void fill(int l, int r, bool f) {
  int a = sum(1, 0, l) & 1, x = sum(1, l - 1, l), c = sum(1, 0, r - 1) & 1,
      y = sum(1, r - 1, r);
  if (a ^ f) set(1, l - 1, l, !x);
  if (c ^ f) set(1, r - 1, r, !y);
  set(1, l, r - 1, 0);
}
long long mex() {
  if (!sum(1, 0, 1)) return 1;
  int l = 1, r = o[0];
  for (int m = (l + r) >> 1; l <= r; m = (l + r) >> 1) {
    if (sum(1, 0, m) < 2)
      l = m + 1;
    else
      r = m - 1;
  }
  return o[l];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%lld%lld", &q[2][i + 1], &b[i << 1].x, &b[i << 1 | 1].x);
    ++b[i << 1 | 1].x;
    b[i << 1].d = b[i << 1 | 1].d = i + 1;
    b[i << 1].s = false;
    b[i << 1 | 1].s = true;
  }
  std::sort(b, b + (n << 1));
  for (int i = 0; i < n << 1; i++) {
    if (!i || b[i].x != b[i - 1].x) o[++o[0]] = b[i].x;
    q[b[i].s][b[i].d] = o[0];
  }
  if (o[1] > 1) {
    for (int i = 1; i <= n; i++) puts("1");
    return 0;
  }
  build(1, 0, o[0]);
  for (int i = 1; i <= n; i++) {
    switch (q[2][i]) {
      case 1:
        fill(q[0][i], q[1][i], true);
        break;
      case 2:
        fill(q[0][i], q[1][i], false);
        break;
      case 3:
        set(1, q[0][i] - 1, q[0][i], !sum(1, q[0][i] - 1, q[0][i]));
        set(1, q[1][i] - 1, q[1][i], !sum(1, q[1][i] - 1, q[1][i]));
        break;
      default:
        while (true) puts("FUCK YOU!");
    }
    printf("%lld\n", mex());
  }
  return 0;
}