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;
inline long long read() {
  long long sum = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  if (f) return -sum;
  return sum;
}
const int N = 20000005;
const long long INF = 1000000000000000001LL;
int rt, cnt, ls[N], rs[N];
bool rev[N], t0[N], t1[N], A1[N], A0[N], op;
inline void T0(int p) {
  t0[p] = A0[p] = 1;
  t1[p] = A1[p] = 0;
  rev[p] = 0;
}
inline void T1(int p) {
  t1[p] = A1[p] = 1;
  t0[p] = A0[p] = 0;
  rev[p] = 0;
}
inline void RV(int p) {
  rev[p] ^= 1;
  swap(A0[p], A1[p]);
  swap(t0[p], t1[p]);
}
inline void NW(int &p) {
  if (!p) p = ++cnt, A0[p] = 1;
}
inline void push(int p) {
  int &l = ls[p], &r = rs[p];
  NW(l);
  NW(r);
  if (rev[p]) rev[p] = 0, RV(l), RV(r);
  if (t0[p]) t0[p] = 0, T0(l), T0(r);
  if (t1[p]) t1[p] = 0, T1(l), T1(r);
}
inline void to(int &p, long long l, long long r, long long L, long long R) {
  NW(p);
  if (l == L && r == R) {
    op ? T1(p) : T0(p);
    return;
  }
  long long mid = (l + r) >> 1;
  push(p);
  if (R <= mid)
    to(ls[p], l, mid, L, R);
  else if (L > mid)
    to(rs[p], mid + 1, r, L, R);
  else
    to(ls[p], l, mid, L, mid), to(rs[p], mid + 1, r, mid + 1, R);
  A1[p] = (ls[p] && A1[ls[p]] && rs[p] && A1[rs[p]]);
  A0[p] = ((!ls[p] || A0[ls[p]]) && (!rs[p] || A0[rs[p]]));
}
inline void rv(int &p, long long l, long long r, long long L, long long R) {
  NW(p);
  if (l == L && r == R) {
    RV(p);
    return;
  }
  long long mid = (l + r) >> 1;
  push(p);
  if (R <= mid)
    rv(ls[p], l, mid, L, R);
  else if (L > mid)
    rv(rs[p], mid + 1, r, L, R);
  else
    rv(ls[p], l, mid, L, mid), rv(rs[p], mid + 1, r, mid + 1, R);
  A1[p] = (ls[p] && A1[ls[p]] && rs[p] && A1[rs[p]]);
  A0[p] = ((!ls[p] || A0[ls[p]]) && (!rs[p] || A0[rs[p]]));
}
inline long long mex(int p, long long l, long long r) {
  if (!p || l == r) return l;
  long long mid = (l + r) >> 1;
  push(p);
  if (ls[p] && A1[ls[p]])
    return mex(rs[p], mid + 1, r);
  else
    return mex(ls[p], l, mid);
}
int main() {
  int T = read(), tp;
  long long l, r;
  while (T--) {
    tp = read();
    l = read();
    r = read();
    if (tp == 1)
      op = 1, to(rt, 1, INF, l, r);
    else if (tp == 2)
      op = 0, to(rt, 1, INF, l, r);
    else
      rv(rt, 1, INF, l, r);
    printf("%lld\n", mex(rt, 1, INF));
  }
  return 0;
}