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 long long maxn = 3e5 + 5;
long long mex[4 * maxn], mix[4 * maxn], lazy[4 * maxn], lazyadd[4 * maxn],
    lazyrem[4 * maxn], inf;
vector<long long> compress;
map<long long, long long> M;
struct Query {
  long long t, l, r;
};
void build(long long id, long long L, long long R) {
  mex[id] = compress[L];
  mix[id] = inf;
  if (R == L + 1) return;
  long long mid = (L + R) / 2;
  build(2 * id + 0, L, mid);
  build(2 * id + 1, mid, R);
}
void relax(long long id, long long L, long long R) {
  long long mid = (L + R) / 2;
  if (R == L + 1) return;
  if (lazyadd[id]) {
    lazyadd[id] = 0;
    lazyadd[2 * id] = lazyadd[2 * id + 1] = 1;
    lazyrem[2 * id] = lazyrem[2 * id + 1] = 0;
    lazy[2 * id] = lazy[2 * id + 1] = 0;
    mex[2 * id] = mex[2 * id + 1] = inf;
    mix[2 * id] = compress[L];
    mix[2 * id + 1] = compress[mid];
  }
  if (lazyrem[id]) {
    lazyrem[id] = 0;
    lazyrem[2 * id] = lazyrem[2 * id + 1] = 1;
    lazyadd[2 * id] = lazyadd[2 * id + 1] = 0;
    lazy[2 * id] = lazy[2 * id + 1] = 0;
    mix[2 * id] = mix[2 * id + 1] = inf;
    mex[2 * id] = compress[L];
    mex[2 * id + 1] = compress[mid];
  }
  if (lazy[id]) {
    lazy[id] = 0;
    lazy[2 * id + 0] ^= 1;
    lazy[2 * id + 1] ^= 1;
    swap(mex[2 * id], mix[2 * id]);
    swap(mex[2 * id + 1], mix[2 * id + 1]);
  }
}
void add(long long id, long long L, long long R, long long l, long long r,
         long long t) {
  if (r <= L || R <= l) return;
  if (L >= l && R <= r) {
    if (t == 1) {
      mix[id] = compress[L];
      mex[id] = inf;
      lazyadd[id] = 1;
      lazyrem[id] = 0;
      lazy[id] = 0;
    } else if (t == 2) {
      mix[id] = inf;
      mex[id] = compress[L];
      lazyadd[id] = 0;
      lazyrem[id] = 1;
      lazy[id] = 0;
    } else {
      swap(mex[id], mix[id]);
      lazy[id] ^= 1;
    }
    return;
  }
  long long mid = (L + R) / 2;
  relax(id, L, R);
  add(2 * id + 0, L, mid, l, r, t);
  add(2 * id + 1, mid, R, l, r, t);
  mex[id] = min(mex[2 * id], mex[2 * id + 1]);
  mix[id] = min(mix[2 * id], mix[2 * id + 1]);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  Query Q[n];
  for (long long i = 0; i < n; i++) {
    cin >> Q[i].t >> Q[i].l >> Q[i].r;
    compress.push_back(Q[i].l);
    compress.push_back(Q[i].r);
    compress.push_back(Q[i].r + 1);
  }
  compress.push_back(1);
  sort(compress.begin(), compress.end());
  compress.resize(unique(compress.begin(), compress.end()) - compress.begin());
  inf = compress.back() + 1;
  compress.push_back(inf);
  long long sz = compress.size();
  for (long long i = 0; i < sz; i++) {
    M[compress[i]] = i;
  }
  build(1, 0, sz);
  for (long long i = 0; i < n; i++) {
    Q[i].l = M[Q[i].l];
    Q[i].r = M[Q[i].r];
    add(1, 0, sz, Q[i].l, Q[i].r + 1, Q[i].t);
    cout << mex[1] << '\n';
  }
}