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 int maxn = 500000 + 7;
int q, m, vs, as;
int op[maxn], T[maxn * 4], tag[maxn * 4];
long long l[maxn], r[maxn], a[maxn], v[maxn];
map<long long, long long> M;
void init() {
  vs = 0;
  for (int i = 1; i <= q; i++) v[++vs] = l[i], v[++vs] = r[i];
  sort(v + 1, v + vs + 1);
  as = 0;
  for (int i = 1; i <= vs; i++) a[++as] = v[i], a[++as] = v[i] + 1;
  sort(a + 1, a + as + 1);
  m = (unique(a + 1, a + as + 1) - a) - 1;
  if (a[1] != 1) {
    for (int i = m; i >= 1; i--) a[i + 1] = a[i];
    a[1] = 1;
    ++m;
  }
  for (int i = 1; i <= m; i++) M[a[i]] = i;
  for (int i = 1; i <= q; i++) l[i] = M[l[i]], r[i] = M[r[i]];
}
void update(int k, int l, int r, int op) {
  if (op == 1) T[k] = r - l + 1;
  if (op == 2) T[k] = 0;
  if (op == 3) T[k] = (r - l + 1) - T[k];
  if (l < r) {
    if (op <= 2)
      tag[k] = op;
    else {
      if (tag[k] <= 2)
        tag[k] = 3 - tag[k];
      else
        tag[k] = 0;
    }
  }
}
void pushdown(int k, int l, int r) {
  int mid = (l + r) >> 1;
  update((k << 1), l, mid, tag[k]);
  update((k << 1) | 1, mid + 1, r, tag[k]);
  tag[k] = 0;
}
void add(int k, int l, int r, int x, int y, int op) {
  if (tag[k]) pushdown(k, l, r);
  if ((x <= l) && (r <= y))
    update(k, l, r, op);
  else {
    int mid = (l + r) >> 1;
    if (x <= mid) add(k << 1, l, mid, x, y, op);
    if (y > mid) add((k << 1) | 1, mid + 1, r, x, y, op);
    T[k] = T[k << 1] + T[(k << 1) | 1];
  }
}
int query(int k, int l, int r) {
  if (tag[k]) pushdown(k, l, r);
  if (l == r) return l;
  int mid = (l + r) >> 1;
  if (T[k << 1] == (mid - l + 1))
    return query((k << 1) | 1, mid + 1, r);
  else
    query(k << 1, l, mid);
}
int main() {
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) scanf("%I64d%I64d%I64d", &op[i], &l[i], &r[i]);
  init();
  for (int i = 1; i <= q; i++) {
    add(1, 1, m, l[i], r[i], op[i]);
    printf("%I64d\n", a[query(1, 1, m)]);
  }
  return 0;
}