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 N = 1e5 + 10;
struct {
  int op;
  long long l, r;
} e[N];
long long b[N << 2];
struct {
  char v, tag;
  void upd(char x) { v = x, tag = 0; }
  void flip() {
    if (v != -1)
      v ^= 1;
    else
      tag ^= 1;
  }
} tr[N << 4];
int n;
void pd(int o) {
  if (tr[o].tag) {
    tr[o << 1].flip();
    tr[o << 1 | 1].flip();
    tr[o].tag = 0;
  } else if (tr[o].v != -1) {
    tr[o << 1].upd(tr[o].v);
    tr[o << 1 | 1].upd(tr[o].v);
  }
}
void pu(int &o) {
  tr[o].v = tr[o << 1].v == tr[o << 1 | 1].v ? tr[o << 1].v : -1;
}
void upd(int o, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) return tr[o].upd(v);
  int mid = (l + r) / 2;
  pd(o);
  if (mid >= ql) upd(o << 1, l, mid, ql, qr, v);
  if (mid < qr) upd(o << 1 | 1, mid + 1, r, ql, qr, v);
  pu(o);
}
void flip(int o, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) return tr[o].flip();
  int mid = (l + r) / 2;
  pd(o);
  if (mid >= ql) flip(o << 1, l, mid, ql, qr);
  if (mid < qr) flip(o << 1 | 1, mid + 1, r, ql, qr);
  pu(o);
}
long long query(int o, int l, int r) {
  if (tr[o].v == 0) return l;
  if (tr[o].v == 1) return r + 1;
  int mid = (l + r) / 2;
  pd(o);
  if (tr[o << 1].v == 1) {
    int t = query(o << 1 | 1, mid + 1, r);
    return t == -1 ? mid : t;
  }
  return query(o << 1, l, mid);
}
int main() {
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d%lld%lld", &e[i].op, &e[i].l, &e[i].r);
    b[++cnt] = e[i].l;
    b[++cnt] = ++e[i].r;
  }
  b[++cnt] = 1;
  sort(b + 1, b + 1 + cnt);
  cnt = unique(b + 1, b + 1 + cnt) - b - 1;
  for (int i = 1; i <= n; ++i) {
    int l = lower_bound(b + 1, b + 1 + cnt, e[i].l) - b;
    int r = lower_bound(b + 1, b + 1 + cnt, e[i].r) - b - 1;
    if (e[i].op == 1)
      upd(1, 1, cnt - 1, l, r, 1);
    else if (e[i].op == 2)
      upd(1, 1, cnt - 1, l, r, 0);
    else
      flip(1, 1, cnt - 1, l, r);
    printf("%lld\n", b[query(1, 1, cnt - 1)]);
  }
}