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;
template <typename T>
void cmax(T& x, T y) {
  if (x < y) x = y;
}
template <typename T>
void cmin(T& x, T y) {
  if (x > y) x = y;
}
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
const int N = 4e6, M = 1e5 + 5;
const long long INF = 2e18;
int n, rt, tot, t1[N], t2[N], len;
long long v[2][N], a[M], b[M], c[M], d[N];
inline void build(int rt, int l, int r) {
  t1[rt] = -1, v[0][rt] = l, v[1][rt] = INF;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
}
inline void pd(int rt, long long l, long long r) {
  long long mid = (l + r) / 2;
  if (t1[rt] != -1) v[t1[rt]][rt << 1] = l, v[t1[rt] ^ 1][rt << 1] = INF;
  if (t2[rt]) swap(v[0][rt << 1], v[1][rt << 1]);
  if (t1[rt] != -1)
    v[t1[rt]][rt << 1 | 1] = mid + 1, v[t1[rt] ^ 1][rt << 1 | 1] = INF;
  if (t2[rt]) swap(v[0][rt << 1 | 1], v[1][rt << 1 | 1]);
  if (t1[rt] != -1)
    t1[rt << 1] = t1[rt << 1 | 1] = t1[rt] ^ t2[rt],
             t2[rt << 1] = t2[rt << 1 | 1] = 0;
  else
    t2[rt << 1] ^= t2[rt], t2[rt << 1 | 1] ^= t2[rt];
  t1[rt] = -1, t2[rt] = 0;
}
inline void cov(int rt, long long l, long long r, long long L, long long R,
                int p) {
  if (L <= l && r <= R) {
    if (p == 2)
      t2[rt] ^= 1, swap(v[0][rt], v[1][rt]);
    else
      t2[rt] = 0, t1[rt] = p, v[p][rt] = l, v[p ^ 1][rt] = INF;
    return;
  }
  pd(rt, l, r);
  long long mid = (l + r) / 2;
  if (mid >= L) cov(rt << 1, l, mid, L, R, p);
  if (mid < R) cov(rt << 1 | 1, mid + 1, r, L, R, p);
  v[0][rt] = min(v[0][rt << 1], v[0][rt << 1 | 1]);
  v[1][rt] = min(v[1][rt << 1], v[1][rt << 1 | 1]);
}
inline int find(long long x) { return lower_bound(d + 1, d + len + 1, x) - d; }
int main() {
  n = read(), d[++len] = 1;
  for (int i = (1), iend = (n); i <= iend; i++) {
    a[i] = read(), b[i] = read(), c[i] = read();
    d[++len] = b[i], d[++len] = c[i], d[++len] = c[i] + 1;
  }
  sort(d + 1, d + len + 1);
  len = unique(d + 1, d + len + 1) - d - 1;
  build(1, 1, len);
  for (int i = (1), iend = (n); i <= iend; i++) {
    int l = find(b[i]), r = find(c[i]);
    if (a[i] == 1) cov(1, 1, len, l, r, 1);
    if (a[i] == 2) cov(1, 1, len, l, r, 0);
    if (a[i] == 3) cov(1, 1, len, l, r, 2);
    printf("%lld\n", d[v[0][1]]);
  }
}