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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
const int maxn = 524288, maxt = 123456;
int op[maxt], F[maxn * 2], S[maxn * 2];
long long X[maxn], Y[maxt], Z[maxt], L[maxn * 2], R[maxn * 2], SIZ[maxn * 2];
map<long long, int> W;
inline long long read() {
  register char c;
  long long res = 0;
  while (c = getchar(), c < '0' || c > '9')
    ;
  do {
    res = (res << 1) + (res << 3) + (c ^ 48);
  } while (c = getchar(), c >= '0' && c <= '9');
  return res;
}
void build(int rt) {
  if (rt >= maxn) return;
  build(rt << 1);
  build(rt << 1 | 1);
  L[rt] = L[rt << 1];
  R[rt] = R[rt << 1] + R[rt << 1 | 1];
}
void pushdown(int rt) {
  if (S[rt]) {
    if (~(S[rt << 1] = S[rt << 1 | 1] = S[rt])) {
      SIZ[rt << 1] = R[rt << 1];
      SIZ[rt << 1 | 1] = R[rt << 1 | 1];
    } else
      SIZ[rt << 1] = SIZ[rt << 1 | 1] = 0;
    F[rt << 1] = F[rt << 1 | 1] = S[rt] = 0;
  } else if (F[rt]) {
    F[rt] = 0;
    if (F[rt << 1])
      F[rt << 1] = 0;
    else if (S[rt << 1])
      S[rt << 1] = -S[rt << 1];
    else
      F[rt << 1] = 1;
    SIZ[rt << 1] = R[rt << 1] - SIZ[rt << 1];
    if (F[rt << 1 | 1])
      F[rt << 1 | 1] = 0;
    else if (S[rt << 1 | 1])
      S[rt << 1 | 1] = -S[rt << 1 | 1];
    else
      F[rt << 1 | 1] = 1;
    SIZ[rt << 1 | 1] = R[rt << 1 | 1] - SIZ[rt << 1 | 1];
  }
}
void sett(int l, int r, int _l, int _r, int rt, int setx) {
  if (_l >= l && _r <= r) {
    F[rt] = 0;
    S[rt] = setx;
    SIZ[rt] = ~setx ? R[rt] : 0;
    return;
  }
  int mid = (_l + _r) >> 1;
  pushdown(rt);
  if (mid >= l) sett(l, r, _l, mid, rt << 1, setx);
  if (mid < r) sett(l, r, mid + 1, _r, rt << 1 | 1, setx);
  SIZ[rt] = SIZ[rt << 1] + SIZ[rt << 1 | 1];
  return;
}
void flip(int l, int r, int _l, int _r, int rt) {
  if (_l >= l && _r <= r) {
    if (F[rt])
      F[rt] = 0;
    else if (S[rt])
      S[rt] = -S[rt];
    else
      F[rt] = 1;
    SIZ[rt] = R[rt] - SIZ[rt];
    return;
  }
  int mid = (_l + _r) >> 1;
  pushdown(rt);
  if (mid >= l) flip(l, r, _l, mid, rt << 1);
  if (mid < r) flip(l, r, mid + 1, _r, rt << 1 | 1);
  SIZ[rt] = SIZ[rt << 1] + SIZ[rt << 1 | 1];
  return;
}
inline long long query() {
  int i = 1;
  for (; i < maxn;) {
    pushdown(i);
    i <<= 1;
    if (SIZ[i] == R[i]) i++;
  }
  return L[i];
}
int main() {
  int T, j = maxn;
  scanf("%d", &T);
  for (int i = 0; i < T; i++) {
    scanf("%d", op + i);
    X[i << 1] = Y[i] = read();
    X[i << 1 | 1] = Z[i] = read();
  }
  X[T << 1] = 1 + (long long)1e18;
  sort(X, X + 2 * T + 1);
  if (*X - 1) {
    for (int i = 1; i <= T; i++) puts("1");
    return 0;
  }
  for (int i = 0; i <= T << 1; i++) {
    if (X[i] == X[i + 1]) continue;
    L[j] = X[i];
    R[j] = 1;
    W[X[i]] = j - maxn + 1;
    j++;
    if (X[i] + 1 >= X[i + 1]) continue;
    L[j] = X[i] + 1;
    R[j] = X[i + 1] - L[j];
    j++;
  }
  build(1);
  for (int i = 0; i < T; i++) {
    if (op[i] == 1)
      sett(W[Y[i]], W[Z[i]], 1, maxn, 1, 1);
    else if (op[i] == 2)
      sett(W[Y[i]], W[Z[i]], 1, maxn, 1, -1);
    else
      flip(W[Y[i]], W[Z[i]], 1, maxn, 1);
    printf("%I64d\n", query());
  }
  return 0;
}