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 inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 300500;
struct query {
  int tp;
  long long l, r;
  query(){};
  query(int x, long long y, long long z) : tp(x), l(y), r(z){};
} q[N];
long long a[N];
int n, sz, t[N << 2];
bool set0[N << 2], set1[N << 2], inv[N << 2];
inline int get(long long x) {
  int l = 1, r = sz, res;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[mid] <= x) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return res;
}
inline void push(int v, int l, int r) {
  int mid = (l + r) >> 1;
  if (set1[v]) {
    t[v << 1] = mid - l + 1;
    set1[v << 1] = 1;
    t[v << 1 | 1] = r - mid;
    set1[v << 1 | 1] = 1;
    set0[v << 1] = set0[v << 1 | 1] = 0;
    inv[v << 1] = inv[v << 1 | 1] = 0;
    set1[v] = 0;
  }
  if (set0[v]) {
    t[v << 1] = t[v << 1 | 1] = 0;
    set0[v << 1] = set0[v << 1 | 1] = 1;
    set1[v << 1] = set1[v << 1 | 1] = 0;
    inv[v << 1] = inv[v << 1 | 1] = 0;
    set0[v] = 0;
  }
  if (inv[v]) {
    t[v << 1] = mid - l + 1 - t[v << 1];
    inv[v << 1] ^= 1;
    t[v << 1 | 1] = r - mid - t[v << 1 | 1];
    inv[v << 1 | 1] ^= 1;
    inv[v] = 0;
  }
}
void upd1(int v, int l, int r, int lx, int rx) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    set1[v] = 1;
    set0[v] = 0;
    inv[v] = 0;
    t[v] = r - l + 1;
    return;
  }
  push(v, l, r);
  int mid = (l + r) >> 1;
  upd1(v << 1, l, mid, lx, rx);
  upd1(v << 1 | 1, mid + 1, r, lx, rx);
  t[v] = t[v << 1] + t[v << 1 | 1];
}
void upd0(int v, int l, int r, int lx, int rx) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    set0[v] = 1;
    set1[v] = 0;
    inv[v] = 0;
    t[v] = 0;
    return;
  }
  push(v, l, r);
  int mid = (l + r) >> 1;
  upd0(v << 1, l, mid, lx, rx);
  upd0(v << 1 | 1, mid + 1, r, lx, rx);
  t[v] = t[v << 1] + t[v << 1 | 1];
}
void invert(int v, int l, int r, int lx, int rx) {
  if (rx < l || r < lx) return;
  if (lx <= l && r <= rx) {
    t[v] = r - l + 1 - t[v];
    inv[v] ^= 1;
    return;
  }
  push(v, l, r);
  int mid = (l + r) >> 1;
  invert(v << 1, l, mid, lx, rx);
  invert(v << 1 | 1, mid + 1, r, lx, rx);
  t[v] = t[v << 1] + t[v << 1 | 1];
}
int get(int v, int l, int r) {
  if (l == r) return r;
  push(v, l, r);
  int mid = (l + r) >> 1;
  if (t[v << 1] == mid - l + 1)
    return get(v << 1 | 1, mid + 1, r);
  else
    return get(v << 1, l, mid);
}
int main() {
  scanf("%d", &n);
  a[++sz] = 1;
  for (int i = 1; i <= n; i++) {
    int tp;
    long long l, r;
    scanf("%d %I64d %I64d", &tp, &l, &r);
    q[i] = query(tp, l, r);
    a[++sz] = l;
    a[++sz] = r;
    a[++sz] = r + 1;
  }
  sort(a + 1, a + 1 + sz);
  sz = unique(a + 1, a + 1 + sz) - a - 1;
  for (int i = 1; i <= n; i++) {
    q[i].l = get(q[i].l);
    q[i].r = get(q[i].r);
  }
  for (int i = 1; i <= n; i++) {
    if (q[i].tp == 1)
      upd1(1, 1, sz, q[i].l, q[i].r);
    else if (q[i].tp == 2)
      upd0(1, 1, sz, q[i].l, q[i].r);
    else
      invert(1, 1, sz, q[i].l, q[i].r);
    printf("%I64d\n", a[get(1, 1, sz)]);
  }
  return 0;
}