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 = 100006;
const int nein = -1;
struct qr {
  long long o, l, r;
};
vector<long long> vals;
vector<qr> q;
struct Segment_Tree {
  vector<int> val, lazy;
  int size;
  void init(int x) {
    size = 1;
    while (size < x) size *= 2;
    val.resize(size * 2);
    lazy.resize(size * 2);
  }
  void propagate(int node, int l, int r) {
    if (l == r - 1) {
      lazy[node] = nein;
      return;
    }
    if (lazy[node] == nein) {
      return;
    }
    int mid = (l + r) / 2;
    for (int x : {2 * node + 1, 2 * node + 2}) {
      if (lazy[node] == 0) {
        val[x] = 0;
        lazy[x] = 0;
      }
      if (lazy[node] == 1) {
        val[x] = mid - l;
        lazy[x] = 1;
      }
      if (lazy[node] == 2) {
        val[x] = mid - l - val[x];
        lazy[x] = 1 - lazy[x];
      }
    }
    lazy[node] = nein;
  }
  int merge(int a, int b) { return a + b; }
  void add(int node, int l, int r, int lf, int rg, int x) {
    propagate(node, l, r);
    if (r <= lf || l >= rg) return;
    if (l >= lf && r <= rg) {
      val[node] = x * (r - l);
      lazy[node] = x;
      return;
    }
    int mid = (l + r) / 2;
    add(node * 2 + 1, l, mid, lf, rg, x);
    add(node * 2 + 2, mid, r, lf, rg, x);
    val[node] = merge(val[node * 2 + 1], val[node * 2 + 2]);
  }
  void add(int l, int r, int x) { add(0, 0, size, l, r, x); }
  void rev(int node, int l, int r, int lf, int rg) {
    propagate(node, l, r);
    if (r <= lf || l >= rg) return;
    if (l >= lf && r <= rg) {
      val[node] = r - l - val[node];
      if (lazy[node] == -1)
        lazy[node] = 2;
      else
        lazy[node] = 1 - lazy[node];
      return;
    }
    int mid = (l + r) / 2;
    rev(node * 2 + 1, l, mid, lf, rg);
    rev(node * 2 + 2, mid, r, lf, rg);
    val[node] = merge(val[node * 2 + 1], val[node * 2 + 2]);
  }
  void rev(int l, int r) { rev(0, 0, size, l, r); }
  int get(int node, int l, int r) {
    propagate(node, l, r);
    if (val[node] == r - l) return -1;
    if (l == r - 1) {
      return l;
    }
    int mid = (l + r) / 2;
    int ans = get(node * 2 + 1, l, mid);
    if (ans == -1) ans = get(node * 2 + 2, mid, r);
    return ans;
  }
  int get() { return get(0, 0, size); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long op, x, y;
    cin >> op >> x >> y;
    q.push_back(qr{op, x, y});
    vals.push_back(x);
    vals.push_back(y);
    vals.push_back(y + 1);
  }
  vals.push_back(1);
  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());
  for (int i = 1; i <= n; i++) {
    q[i - 1].l =
        lower_bound(vals.begin(), vals.end(), q[i - 1].l) - vals.begin();
    q[i - 1].r =
        lower_bound(vals.begin(), vals.end(), q[i - 1].r) - vals.begin();
  }
  Segment_Tree st;
  st.init(6 * n);
  for (auto it : q) {
    if (it.o == 1) {
      st.add(it.l, it.r + 1, 1);
    } else if (it.o == 2) {
      st.add(it.l, it.r + 1, 0);
    } else if (it.o == 3) {
      st.rev(it.l, it.r + 1);
    }
    cout << vals[st.get()] << '\n';
  }
  return 0;
}