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 INF = 1e9, MOD = INF + 7;
const int N = 1e5 + 10;
int n, qt[N], seg[4 * 2 * N], lazy[4 * 2 * N];
long long ql[N], qr[N];
void apply(int id, int s, int e, int t) {
  if (t == 1) seg[id] = e - s, lazy[id] = 1;
  if (t == 2) seg[id] = 0, lazy[id] = 2;
  if (t == 3) seg[id] = e - s - seg[id], lazy[id] = 3 - lazy[id];
}
void shift(int id, int s, int e) {
  if (lazy[id] == 0) return;
  int md = (s + e) / 2;
  apply(2 * id, s, md, lazy[id]);
  apply(2 * id + 1, md, e, lazy[id]);
  lazy[id] = 0;
}
void update(int l, int r, int t, int id = 1, int s = 0, int e = n) {
  if (l >= e || s >= r) return;
  if (l <= s && e <= r) {
    apply(id, s, e, t);
    return;
  }
  shift(id, s, e);
  int md = (s + e) / 2;
  update(l, r, t, 2 * id, s, md);
  update(l, r, t, 2 * id + 1, md, e);
  seg[id] = seg[2 * id] + seg[2 * id + 1];
}
int get(int id = 1, int s = 0, int e = n) {
  if (seg[id] == 0 || e - s < 2) return s;
  shift(id, s, e);
  int md = (s + e) / 2;
  if (seg[2 * id] == md - s)
    return get(2 * id + 1, md, e);
  else
    return get(2 * id, s, md);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  vector<long long> v;
  v.push_back(0);
  for (int i = 0; i < q; i++) {
    cin >> qt[i] >> ql[i] >> qr[i];
    ql[i]--;
    v.push_back(ql[i]);
    v.push_back(qr[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  n = (int)(v.size());
  for (int i = 0; i < q; i++) {
    int t = qt[i];
    int l = lower_bound(v.begin(), v.end(), ql[i]) - v.begin();
    int r = lower_bound(v.begin(), v.end(), qr[i]) - v.begin();
    update(l, r, t);
    int idx = get();
    cout << v[idx] + 1 << "\n";
  }
  return 0;
}