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;
template <typename T1, typename T2>
void Max(T1& a, T2 b) {
  a = max(a, (T1)b);
}
template <typename T1, typename T2>
void Min(T1& a, T2 b) {
  a = min(a, (T1)b);
}
template <typename T, typename AD>
struct ST {
  vector<T> st;
  vector<AD> lazy;
  int n;
  static T combine(T a, T b) { return a + b; }
  void add(int i, int sz, AD change) {
    if (change == 1)
      st[i] = sz;
    else if (change == 2)
      st[i] = 0;
    else
      st[i] = sz - st[i];
    if (sz > 1) {
      if (change == 1 || change == 2)
        lazy[i] = change;
      else {
        lazy[i] = 3 - lazy[i];
      }
    }
  }
  void init(int _n) {
    n = _n;
    int sz = 1;
    while (sz < n) sz <<= 1;
    st.assign(sz << 1, T());
    lazy.assign(sz, T());
  }
  void init(T* a, int _n) {
    init(_n);
    build(1, 0, n - 1, a);
  }
  void _build(int i, int l, int r, T* a) {
    if (l == r) {
      st[i] = a[l];
      return;
    }
    int m = l + r >> 1;
    _build(i << 1, l, m, a);
    _build(i << 1 | 1, m + 1, r, a);
    st[i] = combine(st[i << 1], st[i << 1 | 1]);
  }
  void _push(int i, int l, int m, int r) {
    if (!lazy[i]) return;
    add(i << 1, m - l + 1, lazy[i]);
    add(i << 1 | 1, r - m, lazy[i]);
    lazy[i] = T();
  }
  T query(int a, int b) { return _query(1, 0, n - 1, a, b); }
  T _query(int i, int l, int r, int a, int b) {
    if (b < l || a > r) return T();
    if (l >= a && r <= b) return st[i];
    int m = l + r >> 1;
    _push(i, l, m, r);
    return combine(_query(i << 1, l, m, a, b),
                   _query(i << 1 | 1, m + 1, r, a, b));
  }
  void update(int a, int b, AD change) { _update(1, 0, n - 1, a, b, change); }
  void _update(int i, int l, int r, int a, int b, AD change) {
    if (l >= a && r <= b) {
      add(i, r - l + 1, change);
      return;
    }
    int m = l + r >> 1;
    _push(i, l, m, r);
    if (a <= m) _update(i << 1, l, m, a, b, change);
    if (b > m) _update(i << 1 | 1, m + 1, r, a, b, change);
    st[i] = combine(st[i << 1], st[i << 1 | 1]);
  }
};
struct GetID2 {
  map<long long, int> ids;
  vector<long long> values;
  void clear() {
    ids.clear();
    values.clear();
  }
  int size() const { return (int)values.size(); }
  template <typename T>
  int get(T&& x) {
    auto ret = ids.emplace(forward<T>(x), size());
    if (ret.second) values.push_back(ret.first->first);
    return ret.first->second;
  }
  long long getstr(int id) { return values[id]; }
};
const int N = 100000;
long long l[N], r[N], a[N * 2 + 1];
int t[N];
void solve() {
  long long m;
  cin >> m;
  a[0] = 1;
  for (int i = 0; i < (m); ++i) {
    cin >> t[i] >> l[i] >> r[i];
    r[i]++;
    a[i * 2 + 1] = l[i];
    a[i * 2 + 2] = r[i];
  }
  sort(a, a + 2 * m + 1);
  int n = unique(a, a + 2 * m + 1) - a;
  ST<int, int> st;
  st.init(n);
  for (int i = 0; i < (m); ++i) {
    int x = lower_bound(a, a + n, l[i]) - a;
    int y = lower_bound(a, a + n, r[i]) - a;
    st.update(x, y - 1, t[i]);
    int l = 0, r = n - 1;
    int j = 1;
    while (l < r) {
      int m = l + r >> 1;
      st._push(j, l, m, r);
      j <<= 1;
      if (st.st[j] < m - l + 1) {
        r = m;
      } else {
        j++;
        l = m + 1;
      }
    }
    cout << a[l] << '\n';
  }
}
void init() {}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  init();
  solve();
  return 0;
}