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 long long N = 12e5 + 10;
const long long M = 1e5 + 10;
long long n, m;
long long t[M], l[M], r[M], q[M << 2];
long long sum[N], tag[N], rev[N];
inline long long read() {
  long long x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
inline void pushup(long long rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }
inline void build(long long l, long long r, long long rt) {
  sum[rt] = 0;
  rev[rt] = 0;
  tag[rt] = -1;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
inline void pushdown(long long l, long long r, long long rt) {
  long long mid = (l + r) >> 1;
  if (tag[rt] != -1) {
    tag[rt << 1] = tag[rt];
    tag[rt << 1 | 1] = tag[rt];
    rev[rt << 1] = 0;
    rev[rt << 1 | 1] = 0;
    if (tag[rt]) {
      sum[rt << 1] = mid - l + 1;
      sum[rt << 1 | 1] = r - mid;
    } else {
      sum[rt << 1] = 0;
      sum[rt << 1 | 1] = 0;
    }
    tag[rt] = -1;
  }
  if (rev[rt]) {
    if (tag[rt << 1] != -1)
      tag[rt << 1] ^= 1;
    else
      rev[rt << 1] ^= 1;
    if (tag[rt << 1 | 1] != -1)
      tag[rt << 1 | 1] ^= 1;
    else
      rev[rt << 1 | 1] ^= 1;
    sum[rt << 1] = mid - l + 1 - sum[rt << 1];
    sum[rt << 1 | 1] = r - mid - sum[rt << 1 | 1];
    rev[rt] = 0;
  }
}
inline void update(long long t, long long L, long long R, long long l,
                   long long r, long long rt) {
  if (L <= l && r <= R) {
    if (l == r) {
      if (t == 1)
        sum[rt] = 1;
      else if (t == 2)
        sum[rt] = 0;
      else
        sum[rt] ^= 1;
    } else {
      if (t == 1) {
        tag[rt] = 1;
        rev[rt] = 0;
        sum[rt] = r - l + 1;
      }
      if (t == 2) {
        tag[rt] = 0;
        rev[rt] = 0;
        sum[rt] = 0;
      }
      if (t == 3) {
        if (tag[rt] != -1)
          tag[rt] ^= 1;
        else
          rev[rt] ^= 1;
        sum[rt] = r - l + 1 - sum[rt];
      }
    }
    return;
  }
  pushdown(l, r, rt);
  long long mid = (l + r) >> 1;
  if (L <= mid) update(t, L, R, l, mid, rt << 1);
  if (mid < R) update(t, L, R, mid + 1, r, rt << 1 | 1);
  pushup(rt);
}
inline long long query(long long l, long long r, long long rt) {
  if (l == r) return l;
  pushdown(l, r, rt);
  long long mid = (l + r) >> 1;
  if (sum[rt << 1] < mid - l + 1)
    return query(l, mid, rt << 1);
  else
    return query(mid + 1, r, rt << 1 | 1);
}
signed main() {
  m = read();
  q[++n] = 1;
  for (long long i = 1; i <= m; i++) {
    t[i] = read(), l[i] = read(), r[i] = read();
    q[++n] = l[i], q[++n] = r[i], q[++n] = r[i] + 1;
  }
  sort(q + 1, q + 1 + n);
  n = unique(q + 1, q + 1 + n) - (q + 1);
  build(1, n, 1);
  for (long long 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(t[i], l[i], r[i], 1, n, 1);
    printf("%lld\n", q[query(1, n, 1)]);
  }
  return 0;
}