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 = 1e5 + 5;
const int M = 6e5 + 5;
int n, tp[N], sz, t[M * 4], rev[M * 4];
long long l[N], r[N];
vector<long long> vec;
void push(int v, int tl, int tr) {
  if (tl != tr && rev[v]) {
    if (rev[v] == 3) {
      rev[v << 1] = 3 - rev[v << 1];
      rev[v << 1 | 1] = 3 - rev[v << 1 | 1];
    } else {
      rev[v << 1] = rev[v];
      rev[v << 1 | 1] = rev[v];
    }
  }
  if (rev[v] == 1) t[v] = tr - tl + 1;
  if (rev[v] == 2) t[v] = 0;
  if (rev[v] == 3) t[v] = tr - tl + 1 - t[v];
  rev[v] = 0;
}
void upd(int tp, int l, int r, int v = 1, int tl = 0, int tr = sz) {
  push(v, tl, tr);
  if (l > tr || tl > r) return;
  if (l <= tl && tr <= r) {
    rev[v] = tp;
    push(v, tl, tr);
    return;
  }
  int tm = tl + tr >> 1;
  upd(tp, l, r, v << 1, tl, tm);
  upd(tp, l, r, v << 1 | 1, tm + 1, tr);
  t[v] = t[v << 1] + t[v << 1 | 1];
}
int get(int r, int v = 1, int tl = 0, int tr = sz) {
  push(v, tl, tr);
  if (tl > r) return 0;
  if (tr <= r) return t[v];
  int tm = (tl + tr) >> 1;
  return get(r, v << 1, tl, tm) + get(r, v << 1 | 1, tm + 1, tr);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tp[i] >> l[i] >> r[i];
    vec.push_back(l[i]);
    vec.push_back(r[i]);
    vec.push_back(l[i] + 1);
    vec.push_back(r[i] + 1);
    vec.push_back(max(1LL, l[i] - 1));
    vec.push_back(max(1LL, r[i] - 1));
  }
  vec.push_back(1);
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (int i = 1; i <= n; i++) {
    l[i] = lower_bound(vec.begin(), vec.end(), l[i]) - vec.begin();
    r[i] = lower_bound(vec.begin(), vec.end(), r[i]) - vec.begin();
  }
  sz = (int)vec.size() - 1;
  for (int i = 1; i <= n; i++) {
    upd(tp[i], l[i], r[i]);
    int lo = 0, hi = sz;
    while (hi - lo > 1) {
      int md = (lo + hi) >> 1;
      if (get(md) == md + 1)
        lo = md;
      else
        hi = md;
    }
    if (get(lo) != lo + 1) hi = lo;
    cout << vec[hi] << endl;
  }
}