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>
#pragma GCC optimize("O2")
using namespace std;
const int maxn = 1000 * 100 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
long long q, t[maxn], l[maxn], r[maxn], seg[8 * maxn], lazy[8 * maxn],
    sz = 1, n, cnt, lm[8 * maxn];
vector<long long> v;
unordered_map<long long, long long> mp;
inline void shift(int x, int lx, int rx) {
  if (lazy[x]) {
    if (lazy[x] == 3) {
      seg[x] = (rx - lx) - seg[x];
      lazy[x << 1] = 3 - lazy[x << 1];
      lazy[x << 1 | 1] = 3 - lazy[x << 1 | 1];
    } else {
      if (lazy[x] == 1)
        seg[x] = rx - lx;
      else
        seg[x] = 0;
      lazy[x << 1] = lazy[x];
      lazy[x << 1 | 1] = lazy[x];
    }
    lazy[x] = 0;
  }
}
void upd(int l, int r, int v, int x = 1, int lx = 0, int rx = sz) {
  shift(x, lx, rx);
  if (lx >= r || rx <= l) return;
  if (lx >= l && rx <= r) {
    seg[x] = v * (rx - lx);
    if (v == 0)
      lazy[x] = 2;
    else
      lazy[x] = 1;
    shift(x, lx, rx);
    return;
  }
  int mid = lx + rx >> 1;
  upd(l, r, v, x << 1, lx, mid);
  upd(l, r, v, x << 1 | 1, mid, rx);
  seg[x] = seg[x << 1] + seg[x << 1 | 1];
}
void rev(int l, int r, int x = 1, int lx = 0, int rx = sz) {
  shift(x, lx, rx);
  if (lx >= r || rx <= l) return;
  if (lx >= l && rx <= r) {
    lazy[x] = 3 - lazy[x];
    shift(x, lx, rx);
    return;
  }
  int mid = lx + rx >> 1;
  rev(l, r, x << 1, lx, mid);
  rev(l, r, x << 1 | 1, mid, rx);
  seg[x] = seg[x << 1] + seg[x << 1 | 1];
}
int get(int x = 1, int lx = 0, int rx = sz) {
  if (rx - lx == 1) return lx;
  int mid = lx + rx >> 1;
  shift(x, lx, rx);
  shift(x << 1, lx, mid);
  shift(x << 1 | 1, mid, rx);
  if (seg[x << 1] != mid - lx)
    return get(x << 1, lx, mid);
  else
    return get(x << 1 | 1, mid, rx);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> q;
  v.push_back(1ll);
  for (int i = 1; i <= q; i++) {
    cin >> t[i] >> l[i] >> r[i];
    v.push_back(l[i]);
    v.push_back(r[i] + 1);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  n = v.size();
  for (int i = 0; i < v.size(); i++) {
    mp[v[i]] = i;
  }
  while (sz < n) sz *= 2;
  cnt = 1;
  for (int i = 1; i <= q; i++) {
    if (t[i] == 1) {
      upd(mp[l[i]], mp[r[i] + 1], 1);
    }
    if (t[i] == 2) {
      upd(mp[l[i]], mp[r[i] + 1], 0);
    }
    if (t[i] == 3) {
      rev(mp[l[i]], mp[r[i] + 1]);
    }
    cout << v[get()] << endl;
    cnt++;
  }
}