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;
int tree[1050000 + 5], lazy[1050000 + 5];
map<long long, int> compress;
long long uncompress[4 * 100000];
struct query {
  int t;
  long long l, r;
} q[100000 + 5];
void go(int id, int t) {
  if (t == 3)
    lazy[id] ^= 3;
  else
    lazy[id] = t;
}
void go2(int id, int L, int R) {
  int lt = id << 1, rt = lt | 1;
  if (lazy[id]) {
    if (lazy[id] == 1)
      tree[id] = (R - L + 1);
    else if (lazy[id] == 2)
      tree[id] = 0;
    else
      tree[id] = (R - L + 1) - tree[id];
    if (L != R) go(lt, lazy[id]), go(rt, lazy[id]);
    lazy[id] = 0;
  }
}
void update(int id, int L, int R, int rL, int rR, int t) {
  go2(id, L, R);
  if (L > rR or R < rL) return;
  int lt = id << 1, rt = lt | 1, mid = (L + R) >> 1;
  if (L >= rL and R <= rR) {
    if (t == 1)
      tree[id] = (R - L + 1);
    else if (t == 2)
      tree[id] = 0;
    else
      tree[id] = (R - L + 1) - tree[id];
    if (L != R) go(lt, t), go(rt, t);
    return;
  }
  update(lt, L, mid, rL, rR, t);
  update(rt, mid + 1, R, rL, rR, t);
  tree[id] = tree[lt] + tree[rt];
}
int get(int id, int L, int R) {
  int lt = id << 1, rt = lt | 1, mid = (L + R) >> 1;
  if (L == R) return L;
  go2(lt, L, mid);
  go2(rt, mid + 1, R);
  tree[id] = tree[lt] + tree[rt];
  if (tree[lt] != (mid - L + 1))
    return get(lt, L, mid);
  else
    return get(rt, mid + 1, R);
}
int main() {
  ios::sync_with_stdio(false);
  int n, i, sz, j;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> q[i].t >> q[i].l >> q[i].r;
    compress[q[i].l], compress[q[i].r], compress[q[i].r + 1];
  }
  compress[1];
  i = 0;
  for (auto &z : compress) z.second = ++i, uncompress[i] = z.first;
  sz = i;
  for (i = 0; i < n; ++i) {
    update(1, 1, sz, compress[q[i].l], compress[q[i].r], q[i].t);
    cout << uncompress[get(1, 1, sz)] << endl;
  }
  return 0;
}