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 = 5e5 + 10;
long long n, Q, q[N], typ[N], L[N], R[N];
inline long long rint() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
struct lwh {
  long long ls, rs, sum, tag, revtag;
} sgt[N << 2];
inline void pushup(long long p) {
  sgt[p].sum = sgt[p << 1].sum + sgt[p << 1 | 1].sum;
}
inline void pushdown(long long p) {
  long long mid = (sgt[p].ls + sgt[p].rs) >> 1;
  if (sgt[p].tag != -1) {
    sgt[p << 1].tag = sgt[p << 1 | 1].tag = sgt[p].tag;
    sgt[p << 1].revtag = sgt[p << 1 | 1].revtag = 0;
    if (sgt[p].tag)
      sgt[p << 1].sum = mid - sgt[p].ls + 1,
               sgt[p << 1 | 1].sum = sgt[p].rs - mid;
    else
      sgt[p << 1].sum = sgt[p << 1 | 1].sum = 0;
    sgt[p].tag = -1;
  }
  if (sgt[p].revtag) {
    if (sgt[p << 1].tag != -1)
      sgt[p << 1].tag ^= 1;
    else
      sgt[p << 1].revtag ^= 1;
    if (sgt[p << 1 | 1].tag != -1)
      sgt[p << 1 | 1].tag ^= 1;
    else
      sgt[p << 1 | 1].revtag ^= 1;
    sgt[p << 1].sum = mid - sgt[p].ls + 1 - sgt[p << 1].sum,
             sgt[p << 1 | 1].sum = sgt[p].rs - mid - sgt[p << 1 | 1].sum;
    sgt[p].revtag = 0;
  }
}
inline void Build(long long p, long long l, long long r) {
  sgt[p] = (lwh){l, r, 0, -1, 0};
  if (l == r) return;
  long long mid = (l + r) >> 1;
  Build(p << 1, l, mid);
  Build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
inline void update(long long p, long long l, long long r, long long typ) {
  if (l <= sgt[p].ls && r >= sgt[p].rs) {
    if (sgt[p].ls == sgt[p].rs) {
      if (typ == 1)
        sgt[p].sum = 1;
      else if (typ == 2)
        sgt[p].sum = 0;
      else
        sgt[p].sum ^= 1;
    } else {
      if (typ == 1)
        sgt[p].tag = 1, sgt[p].revtag = 0,
        sgt[p].sum = sgt[p].rs - sgt[p].ls + 1;
      else if (typ == 2)
        sgt[p].tag = sgt[p].revtag = sgt[p].sum = 0;
      else {
        if (sgt[p].tag != -1)
          sgt[p].tag ^= 1;
        else
          sgt[p].revtag ^= 1;
        sgt[p].sum = sgt[p].rs - sgt[p].ls + 1 - sgt[p].sum;
      }
    }
    return;
  }
  pushdown(p);
  long long mid = (sgt[p].ls + sgt[p].rs) >> 1;
  if (l <= mid) update(p << 1, l, r, typ);
  if (r > mid) update(p << 1 | 1, l, r, typ);
  pushup(p);
}
inline long long query(long long p) {
  if (sgt[p].ls == sgt[p].rs) return sgt[p].ls;
  pushdown(p);
  long long mid = (sgt[p].ls + sgt[p].rs) >> 1;
  if (sgt[p << 1].sum < mid - sgt[p].ls + 1) return query(p << 1);
  return query(p << 1 | 1);
}
signed main() {
  Q = rint();
  q[++n] = 1;
  for (register long long i = (1), iend = (Q); i <= iend; ++i) {
    typ[i] = rint(), L[i] = rint(), R[i] = rint();
    q[++n] = L[i], q[++n] = R[i], q[++n] = R[i] + 1;
  }
  sort(q + 1, q + n + 1);
  n = unique(q + 1, q + n + 1) - q - 1;
  Build(1, 1, n);
  for (register long long i = (1), iend = (Q); i <= iend; ++i) {
    L[i] = lower_bound(q + 1, q + n + 1, L[i]) - q;
    R[i] = lower_bound(q + 1, q + n + 1, R[i]) - q;
    update(1, L[i], R[i], typ[i]);
    printf("%lld\n", q[query(1)]);
  }
  return 0;
}