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 = 2e5 + 100;
long long seg[4 * N];
long long lazy[4 * N];
long long l[N], r[N], t[N];
vector<long long> vec;
void relax(int id, int L, int R) {
  long long mid = (L + R) / 2;
  if (lazy[id] != 0) {
    if (lazy[id] == 1) {
      seg[2 * id] = (mid - L);
      seg[2 * id + 1] = (R - mid);
      lazy[2 * id] = lazy[2 * id + 1] = 1;
    } else if (lazy[id] == 2) {
      seg[2 * id] = 0;
      seg[2 * id + 1] = 0;
      lazy[2 * id] = lazy[2 * id + 1] = 2;
    } else {
      seg[2 * id] = (mid - L) - seg[2 * id];
      seg[2 * id + 1] = (R - mid) - seg[2 * id + 1];
      if (lazy[2 * id] == 0) {
        lazy[2 * id] = 3;
      } else if (lazy[2 * id] == 1) {
        lazy[2 * id] = 2;
      } else if (lazy[2 * id] == 2) {
        lazy[2 * id] = 1;
      } else {
        lazy[2 * id] = 0;
      }
      if (lazy[2 * id + 1] == 0) {
        lazy[2 * id + 1] = 3;
      } else if (lazy[2 * id + 1] == 1) {
        lazy[2 * id + 1] = 2;
      } else if (lazy[2 * id + 1] == 2) {
        lazy[2 * id + 1] = 1;
      } else {
        lazy[2 * id + 1] = 0;
      }
    }
  }
  lazy[id] = 0;
  return;
}
void upd(int s, int e, int id, int L, int R, int tp) {
  long long mid = (L + R) / 2;
  if (s <= L && R <= e) {
    if (tp == 1) {
      seg[id] = (R - L);
      lazy[id] = 1;
    }
    if (tp == 2) {
      seg[id] = 0;
      lazy[id] = 2;
    }
    if (tp == 3) {
      seg[id] = (R - L) - seg[id];
      if (lazy[id] == 0) {
        lazy[id] = 3;
      } else if (lazy[id] == 1) {
        lazy[id] = 2;
      } else if (lazy[id] == 2) {
        lazy[id] = 1;
      } else {
        lazy[id] = 0;
      }
    }
    return;
  }
  if (e <= L || R <= s) {
    return;
  }
  relax(id, L, R);
  upd(s, e, 2 * id, L, mid, tp);
  upd(s, e, 2 * id + 1, mid, R, tp);
  seg[id] = seg[2 * id] + seg[2 * id + 1];
}
int get(int id, int L, int R) {
  long long mid = (L + R) / 2;
  if (R - L == 1) {
    return L;
  }
  relax(id, L, R);
  if (seg[2 * id] < (mid - L)) {
    return get(2 * id, L, mid);
  } else {
    return get(2 * id + 1, mid, R);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vec.push_back(1);
  long long q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> t[i] >> l[i] >> r[i];
    vec.push_back(l[i]);
    vec.push_back(r[i] + 1);
  }
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (int i = 1; i <= q; i++) {
    l[i] = (int)(lower_bound(vec.begin(), vec.end(), l[i]) - vec.begin());
    r[i] = (int)(lower_bound(vec.begin(), vec.end(), r[i] + 1) - vec.begin());
    upd(l[i], r[i], 1, 0, vec.size(), t[i]);
    cout << vec[get(1, 0, vec.size())] << endl;
  }
  return 0;
}