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;
inline int read() {
  int sum = 0, p = 1;
  char ch = getchar();
  while (!(('0' <= ch && ch <= '9') || ch == '-')) ch = getchar();
  if (ch == '-') p = -1, ch = getchar();
  while ('0' <= ch && ch <= '9') sum = sum * 10 + ch - 48, ch = getchar();
  return sum * p;
}
const int maxn = 150020;
map<long long, int> mp;
int m, cnt;
long long s[maxn * 3], n;
struct qu {
  long long l, r;
  int type;
} a[maxn];
struct node {
  int s, lz, id;
} c[maxn * 10];
inline void make_tree(int o, int l, int r) {
  c[o].s = 0;
  c[o].lz = -1;
  c[o].id = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  make_tree((o << 1), l, mid);
  make_tree((o << 1 | 1), mid + 1, r);
}
void maintain(int o, int l, int r) {
  c[o].s = c[(o << 1)].s + c[(o << 1 | 1)].s;
}
void pushdown(int o, int l, int r) {
  int mid = (l + r) >> 1;
  if (c[o].lz != -1) {
    c[(o << 1)].lz = c[(o << 1 | 1)].lz = c[o].lz;
    c[(o << 1)].s = (mid - l + 1) * c[o].lz;
    c[(o << 1 | 1)].s = (r - mid) * c[o].lz;
    c[(o << 1)].id = c[(o << 1 | 1)].id = 0;
    c[o].lz = -1;
  }
  if (c[o].id) {
    c[(o << 1)].id ^= 1;
    c[(o << 1 | 1)].id ^= 1;
    c[(o << 1)].s = (mid - l + 1) - c[(o << 1)].s;
    c[(o << 1 | 1)].s = (r - mid) - c[(o << 1 | 1)].s;
    c[o].id = 0;
  }
}
inline void updates(int ql, int qr, int x, int o, int l, int r) {
  pushdown(o, l, r);
  if (ql == l && r == qr) {
    c[o].s = (r - l + 1) * x;
    c[o].lz = x;
    c[o].id = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (ql > mid) {
    updates(ql, qr, x, (o << 1 | 1), mid + 1, r);
  } else if (qr <= mid) {
    updates(ql, qr, x, (o << 1), l, mid);
  } else {
    updates(ql, mid, x, (o << 1), l, mid);
    updates(mid + 1, qr, x, (o << 1 | 1), mid + 1, r);
  }
  maintain(o, l, r);
}
inline void updatex(int ql, int qr, int o, int l, int r) {
  pushdown(o, l, r);
  if (ql == l && r == qr) {
    c[o].s = (r - l + 1) - c[o].s;
    c[o].id ^= 1;
    c[o].lz = -1;
    return;
  }
  int mid = (l + r) >> 1;
  if (ql > mid) {
    updatex(ql, qr, (o << 1 | 1), mid + 1, r);
  } else if (qr <= mid) {
    updatex(ql, qr, (o << 1), l, mid);
  } else {
    updatex(ql, mid, (o << 1), l, mid);
    updatex(mid + 1, qr, (o << 1 | 1), mid + 1, r);
  }
  maintain(o, l, r);
}
void init() {
  m = read();
  for (register int i = (1), _end_ = (m); i <= _end_; i++) {
    cin >> a[i].type >> a[i].l >> a[i].r;
    a[i].r++;
    s[++cnt] = a[i].l;
    s[++cnt] = a[i].r;
  }
  s[++cnt] = 1;
  sort(s + 1, s + cnt + 1);
  n = unique(s + 1, s + cnt + 1) - (s + 1);
  for (register int i = (1), _end_ = (n); i <= _end_; i++) mp[s[i]] = i;
  make_tree(1, 1, n);
}
void query(int o, int l, int r) {
  pushdown(o, l, r);
  if (l == r) {
    cout << s[l] << endl;
    return;
  }
  int mid = (l + r) >> 1;
  if (c[(o << 1)].s < mid - l + 1)
    query((o << 1), l, mid);
  else
    query((o << 1 | 1), mid + 1, r);
}
void doing() {
  for (register int i = (1), _end_ = (m); i <= _end_; i++) {
    int type = a[i].type, l = mp[a[i].l], r = mp[a[i].r] - 1;
    if (type == 1) {
      updates(l, r, 1, 1, 1, n);
    } else if (type == 2) {
      updates(l, r, 0, 1, 1, n);
    } else {
      updatex(l, r, 1, 1, n);
    }
    query(1, 1, n);
  }
}
int main() {
  init();
  doing();
  return 0;
}