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 = 100005;
int n;
int segtree[N << 4];
int lazy[N << 4];
map<long long, int> ma;
map<int, long long> mb;
int sz;
int tt[N];
long long ll[N], rr[N];
void shift(int id, int l, int r) {
  if (lazy[id]) {
    if (lazy[id] == 1) {
      segtree[id] = r - l;
      if (l + 1 < r) lazy[id + id] = lazy[id + id + 1] = lazy[id];
    } else if (lazy[id] == 2) {
      segtree[id] = 0;
      if (l + 1 < r) lazy[id + id] = lazy[id + id + 1] = lazy[id];
    } else if (lazy[id] == 3) {
      segtree[id] = r - l - segtree[id];
      if (l + 1 < r)
        lazy[id + id] = 3 - lazy[id + id],
                  lazy[id + id + 1] = 3 - lazy[id + id + 1];
    }
    lazy[id] = 0;
  }
}
void update(int x, int y, int t, int id = 1, int l = 0, int r = sz) {
  shift(id, l, r);
  if (l >= y || r <= x) return;
  if (l >= x && r <= y) {
    if (t == 1)
      segtree[id] = r - l;
    else if (t == 2)
      segtree[id] = 0;
    else if (t == 3)
      segtree[id] = r - l - segtree[id];
    if (l + 1 < r) {
      if (t == 1 || t == 2)
        lazy[id + id] = lazy[id + id + 1] = t;
      else if (t == 3)
        lazy[id + id] = 3 - lazy[id + id],
                  lazy[id + id + 1] = 3 - lazy[id + id + 1];
    }
    return;
  }
  int mid = l + r >> 1;
  update(x, y, t, id + id, l, mid);
  update(x, y, t, id + id + 1, mid, r);
  segtree[id] = segtree[id + id] + segtree[id + id + 1];
}
int query(int id = 1, int l = 0, int r = sz) {
  shift(id, l, r);
  if (l + 1 == r) return l;
  int mid = l + r >> 1;
  int lef = 1 << 30;
  int rig = 1 << 30;
  shift(id + id, l, mid);
  shift(id + id + 1, mid, r);
  if (segtree[id + id] < mid - l)
    lef = query(id + id, l, mid);
  else if (segtree[id + id + 1] < r - mid)
    rig = query(id + id + 1, mid, r);
  return min(lef, rig);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d %lld %lld", tt + i, ll + i, rr + i), ma[ll[i]], ma[rr[i] + 1];
  ma[1];
  for (auto &it : ma) {
    it.second = sz;
    mb[sz] = it.first;
    sz++;
  }
  for (int i = 0; i < n; i++) {
    update(ma[ll[i]], ma[rr[i] + 1], tt[i]);
    int ans = query();
    printf("%lld\n", mb[ans]);
  }
  return 0;
}