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 = 1 << 19;
const int NN = N * 2;
int A[NN];
bool lazy[NN][3];
void push_lazy(int v, int l, int r) {
  if (lazy[v][0]) {
    A[v] = 0;
    if (v < N) {
      lazy[2 * v][0] = lazy[2 * v + 1][0] = 1;
      lazy[2 * v][1] = lazy[2 * v + 1][1] = lazy[2 * v][2] =
          lazy[2 * v + 1][2] = 0;
    }
    lazy[v][0] = 0;
  }
  if (lazy[v][1]) {
    A[v] = r - l + 1;
    if (v < N) {
      lazy[2 * v][0] = lazy[2 * v + 1][0] = lazy[2 * v][2] =
          lazy[2 * v + 1][2] = 0;
      lazy[2 * v][1] = lazy[2 * v + 1][1] = 1;
    }
    lazy[v][1] = 0;
  }
  if (lazy[v][2]) {
    A[v] = r - l + 1 - A[v];
    if (v < N) {
      lazy[2 * v][2] ^= 1;
      lazy[2 * v + 1][2] ^= 1;
    }
    lazy[v][2] = 0;
  }
}
int query(int v, int l, int r) {
  if (v >= N) return v - N;
  push_lazy(v, l, r);
  const int m = (l + r) / 2;
  push_lazy(2 * v, l, m);
  if (A[2 * v] < m - l + 1)
    return query(2 * v, l, m);
  else
    return query(2 * v + 1, m + 1, r);
}
void update(int v, int ql, int qr, int l, int r, int ty) {
  push_lazy(v, l, r);
  if (ql == l && qr == r) {
    lazy[v][ty] = 1;
    push_lazy(v, l, r);
    return;
  }
  const int m = (l + r) / 2;
  if (ql <= m)
    update(2 * v, ql, min(qr, m), l, m, ty);
  else
    push_lazy(2 * v, l, m);
  if (qr > m)
    update(2 * v + 1, max(m + 1, ql), qr, m + 1, r, ty);
  else
    push_lazy(2 * v + 1, m + 1, r);
  A[v] = A[2 * v] + A[2 * v + 1];
}
void rem(int l, int r) { update(1, l, r, 0, N - 1, 0); }
void add(int l, int r) { update(1, l, r, 0, N - 1, 1); }
void flp(int l, int r) { update(1, l, r, 0, N - 1, 2); }
int mex() { return query(1, 0, N - 1); }
vector<long long> coords;
long long inp[100000][3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  coords.push_back(1);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < 3; j++) cin >> inp[i][j];
    coords.push_back(inp[i][1]);
    coords.push_back(inp[i][2]);
    coords.push_back(inp[i][2] + 1);
  }
  sort(coords.begin(), coords.end());
  coords.erase(unique(coords.begin(), coords.end()), coords.end());
  for (int i = 0; i < q; i++) {
    int t = inp[i][0],
        l = distance(coords.begin(),
                     lower_bound(coords.begin(), coords.end(), inp[i][1])),
        r = distance(coords.begin(),
                     lower_bound(coords.begin(), coords.end(), inp[i][2]));
    if (t == 1) add(l, r);
    if (t == 2) rem(l, r);
    if (t == 3) flp(l, r);
    cout << coords[mex()] << '\n';
  }
  return 0;
}