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 = 300000 + 10;
const long long MOD = 1000000000 + 7;
const long long INF = 10000000;
vector<long long> Poi;
unordered_map<long long, long long> koj;
long long q, SEG[4 * N][2], lazy[4 * N];
vector<pair<int, pair<long long, long long>>> Q;
void modify(int id, int l, int r, int x) {
  if (x == -1) return;
  if (x == 0) {
    SEG[id][0] = INF;
    SEG[id][1] = l;
    lazy[id] = x;
    return;
  }
  if (x == 1) {
    SEG[id][0] = l;
    SEG[id][1] = INF;
    lazy[id] = x;
    return;
  }
  if (lazy[id] == -1) {
    swap(SEG[id][0], SEG[id][1]);
    lazy[id] = x;
    return;
  }
  if (lazy[id] == 2) {
    swap(SEG[id][0], SEG[id][1]);
    lazy[id] = -1;
    return;
  }
  if (lazy[id] == 0) {
    SEG[id][0] = l;
    SEG[id][1] = INF;
    lazy[id] = 1;
    return;
  }
  SEG[id][0] = INF;
  SEG[id][1] = l;
  lazy[id] = 0;
  return;
}
void shift(int id, int l, int r) {
  int mid = (l + r) >> 1;
  modify(id << 1, l, mid, lazy[id]);
  modify(id << 1 | 1, mid, r, lazy[id]);
  lazy[id] = -1;
  return;
}
void build(int id, int l, int r) {
  if (r - l == 1) {
    SEG[id][0] = l;
    SEG[id][1] = INF;
    return;
  }
  int mid = (l + r) >> 1;
  build(id << 1, l, mid);
  build(id << 1 | 1, mid, r);
  SEG[id][0] = l;
  SEG[id][1] = INF;
  return;
}
void update(int id, int lq, int rq, int x, int l, int r) {
  if (rq <= l || r <= lq) {
    return;
  }
  if (lq <= l && r <= rq) {
    modify(id, l, r, x);
    return;
  }
  int mid = (l + r) >> 1;
  shift(id, l, r);
  update(id << 1, lq, rq, x, l, mid);
  update(id << 1 | 1, lq, rq, x, mid, r);
  SEG[id][0] = min(SEG[id << 1][0], SEG[id << 1 | 1][0]);
  SEG[id][1] = min(SEG[id << 1][1], SEG[id << 1 | 1][1]);
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    long long x, l, r;
    cin >> x >> l >> r;
    Poi.push_back(l);
    Poi.push_back(r);
    Poi.push_back(r + 1);
    Q.push_back({x, {l, r}});
  }
  Poi.push_back(1);
  sort(Poi.begin(), Poi.end());
  Poi.push_back(1000000000000000001);
  Poi.resize(unique(Poi.begin(), Poi.end()) - Poi.begin());
  for (int i = 0; i < Poi.size(); i++) {
    koj[Poi[i]] = i + 1;
  }
  for (int i = 0; i < 4 * N; i++) {
    SEG[i][0] = INF;
    SEG[i][1] = INF;
  }
  memset(lazy, -1, sizeof lazy);
  build(1, 1, N);
  for (auto u : Q) {
    update(1, koj[u.second.first], koj[u.second.second] + 1, u.first - 1, 1, N);
    cout << Poi[SEG[1][0] - 1] << '\n';
  }
  return 0;
}