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 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18 + 10;
int one[4 * N], lzy[4 * N], n;
pair<pair<long long, long long>, long long> qry[N];
vector<long long> vec;
void shift(int l, int r, int id) {
  int mid = (l + r) / 2;
  if (lzy[id] == 0) return;
  if (lzy[id] == 1) {
    one[2 * id] = mid - l;
    one[2 * id + 1] = r - mid;
    lzy[2 * id] = 1;
    lzy[2 * id + 1] = 1;
  } else if (lzy[id] == 2) {
    one[2 * id] = 0;
    one[2 * id + 1] = 0;
    lzy[2 * id] = 2;
    lzy[2 * id + 1] = 2;
  } else {
    one[2 * id] = mid - l - one[2 * id];
    one[2 * id + 1] = r - mid - one[2 * id + 1];
    lzy[2 * id] = 3 - lzy[2 * id];
    lzy[2 * id + 1] = 3 - lzy[2 * id + 1];
  }
  lzy[id] = 0;
}
void upd(int l, int r, int x, int s = 0, int e = n, int id = 1) {
  if (e <= l || r <= s) return;
  if (l <= s && e <= r) {
    if (x == 1) {
      one[id] = e - s;
      lzy[id] = 1;
    } else if (x == 2) {
      one[id] = 0;
      lzy[id] = 2;
    } else {
      one[id] = e - s - one[id];
      lzy[id] = 3 - lzy[id];
    }
    return;
  }
  shift(s, e, id);
  int mid = (s + e) / 2;
  upd(l, r, x, s, mid, 2 * id);
  upd(l, r, x, mid, e, 2 * id + 1);
  one[id] = one[2 * id] + one[2 * id + 1];
}
int find(int l = 0, int r = n, int id = 1) {
  if (r - l == 1) return l;
  shift(l, r, id);
  int mid = (l + r) / 2;
  if (one[2 * id] < mid - l) return find(l, mid, 2 * id);
  return find(mid, r, 2 * id + 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long t, l, r;
    cin >> t >> l >> r;
    qry[i] = make_pair(make_pair(l, r), t);
    vec.push_back(l);
    vec.push_back(r + 1);
  }
  vec.push_back(1);
  sort((vec).begin(), (vec).end());
  vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());
  n = vec.size();
  for (int i = 0; i < q; i++) {
    int l = lower_bound((vec).begin(), (vec).end(), qry[i].first.first) -
            vec.begin();
    int r = lower_bound((vec).begin(), (vec).end(), qry[i].first.second + 1) -
            vec.begin();
    upd(l, r, qry[i].second);
    cout << vec[find()] << '\n';
  }
  return 0;
}