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, tot, type[200010];
long long l[200010], r[200010], b[200010];
struct tree {
  long long l, r, p0, p1, tag;
} a[200010 << 3];
inline long long read() {
  long long k = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while ('0' <= c && c <= '9') k = k * 10 + c - '0', c = getchar();
  return k * f;
}
void build(int u, int l, int r) {
  a[u].l = l;
  a[u].r = r;
  a[u].p0 = l;
  a[u].p1 = (1e18 + 1);
  if (l < r) {
    build((u << 1), l, ((a[u].l + a[u].r) >> 1));
    build((u << 1 | 1), ((a[u].l + a[u].r) >> 1) + 1, r);
  }
}
inline void pushup(int u) {
  a[u].p0 = min(a[(u << 1)].p0, a[(u << 1 | 1)].p0);
  a[u].p1 = min(a[(u << 1)].p1, a[(u << 1 | 1)].p1);
}
void pushdown(int u) {
  if (a[u].tag == 1) {
    a[(u << 1)].p0 = a[(u << 1 | 1)].p0 = (1e18 + 1);
    a[(u << 1)].p1 = a[(u << 1)].l;
    a[(u << 1 | 1)].p1 = a[(u << 1 | 1)].l;
  } else if (a[u].tag == 2) {
    a[(u << 1)].p1 = a[(u << 1 | 1)].p1 = (1e18 + 1);
    a[(u << 1)].p0 = a[(u << 1)].l;
    a[(u << 1 | 1)].p0 = a[(u << 1 | 1)].l;
  } else {
    swap(a[(u << 1)].p0, a[(u << 1)].p1);
    swap(a[(u << 1 | 1)].p0, a[(u << 1 | 1)].p1);
  }
  if (a[u].tag == 3) {
    if (a[(u << 1)].tag == 1)
      a[(u << 1)].tag = 2;
    else if (a[(u << 1)].tag == 2)
      a[(u << 1)].tag = 1;
    else if (a[(u << 1)].tag == 3)
      a[(u << 1)].tag = 0;
    else
      a[(u << 1)].tag = 3;
    if (a[(u << 1 | 1)].tag == 1)
      a[(u << 1 | 1)].tag = 2;
    else if (a[(u << 1 | 1)].tag == 2)
      a[(u << 1 | 1)].tag = 1;
    else if (a[(u << 1 | 1)].tag == 3)
      a[(u << 1 | 1)].tag = 0;
    else
      a[(u << 1 | 1)].tag = 3;
  } else
    a[(u << 1)].tag = a[(u << 1 | 1)].tag = a[u].tag;
  a[u].tag = 0;
}
void update(int u, int l, int r, int type) {
  if (l <= a[u].l && a[u].r <= r) {
    if (type == 1)
      a[u].p0 = (1e18 + 1), a[u].p1 = a[u].l;
    else if (type == 2)
      a[u].p0 = a[u].l, a[u].p1 = (1e18 + 1);
    else
      swap(a[u].p0, a[u].p1);
    if (type == 3) {
      if (a[u].tag == 1)
        a[u].tag = 2;
      else if (a[u].tag == 2)
        a[u].tag = 1;
      else if (a[u].tag == 3)
        a[u].tag = 0;
      else
        a[u].tag = 3;
    } else
      a[u].tag = type;
    return;
  }
  if (a[u].tag) pushdown(u);
  if (l <= ((a[u].l + a[u].r) >> 1)) update((u << 1), l, r, type);
  if (r > ((a[u].l + a[u].r) >> 1)) update((u << 1 | 1), l, r, type);
  a[u].p0 = min(a[(u << 1)].p0, a[(u << 1 | 1)].p0);
  a[u].p1 = min(a[(u << 1)].p1, a[(u << 1 | 1)].p1);
}
int query(int u, int pos) {
  if (a[u].l == a[u].r) return a[u].p0;
  if (a[u].tag) pushdown(u);
  if (pos <= ((a[u].l + a[u].r) >> 1))
    return query((u << 1), pos);
  else
    return query((u << 1 | 1), pos);
}
int main() {
  m = read();
  b[tot = 1] = 1;
  for (register int i = 1; i <= m; i++) {
    type[i] = read();
    l[i] = b[++tot] = read();
    r[i] = b[++tot] = read() + 1;
  }
  sort(b + 1, b + 1 + tot);
  n = unique(b + 1, b + 1 + tot) - b - 1;
  for (register int i = 1; i <= m; i++)
    l[i] = lower_bound(b + 1, b + 1 + n, l[i]) - b,
    r[i] = lower_bound(b + 1, b + 1 + n, r[i]) - b;
  build(1, 1, n);
  for (register int i = 1; i <= m; i++) {
    update(1, l[i], r[i] - 1, type[i]);
    long long tmp = a[1].p0;
    if (tmp == (1e18 + 1))
      tmp = b[n] + 1;
    else
      tmp = b[tmp];
    printf("%I64d\n", tmp);
  }
  return 0;
}