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 long long maxn = 1e5 + 10;
const long long inf = 0x3f3f3f3f3f3f3f3f;
long long n;
struct node {
  long long f0, f1;
  long long lazy;
  node *l, *r;
  node(long long f0 = inf, long long f1 = inf) : f0(f0), f1(f1) {
    l = nullptr, r = nullptr;
    lazy = 0;
  }
};
node *root;
void upd_lazy(node *no, long long l) {
  if (l == 3) {
    if (no->lazy == 0)
      no->lazy = l;
    else if (no->lazy == 1)
      no->lazy = 2;
    else if (no->lazy == 2)
      no->lazy = 1;
    else
      no->lazy = 0;
  } else
    no->lazy = l;
}
void flush(node *no, long long ini, long long fim) {
  if (no == nullptr || no->lazy == 0) return;
  if (no->lazy == 1)
    no->f0 = inf, no->f1 = ini;
  else if (no->lazy == 2)
    no->f0 = ini, no->f1 = inf;
  else {
    swap(no->f0, no->f1);
  }
  if (ini != fim) {
    long long meio = (ini + fim) / 2;
    if (no->l == nullptr) no->l = new node(ini, inf);
    if (no->r == nullptr) no->r = new node(meio + 1, inf);
    upd_lazy(no->l, no->lazy);
    upd_lazy(no->r, no->lazy);
  }
  no->lazy = 0;
}
void update(node *no, long long l, long long r, long long x, long long ini = 1,
            long long fim = (long long)1e6) {
  flush(no, ini, fim);
  if (l <= ini && fim <= r) {
    upd_lazy(no, x);
    flush(no, ini, fim);
    return;
  }
  long long meio = (ini + fim) / 2;
  if (r <= meio) {
    if (no->l == nullptr) no->l = new node(ini, inf);
    update(no->l, l, r, x, ini, meio);
  } else if (l > meio) {
    if (no->r == nullptr) no->r = new node(meio + 1, inf);
    update(no->r, l, r, x, meio + 1, fim);
  } else {
    if (no->l == nullptr) no->l = new node(ini, inf);
    if (no->r == nullptr) no->r = new node(meio + 1, inf);
    update(no->l, l, r, x, ini, meio);
    update(no->r, l, r, x, meio + 1, fim);
  }
  if (no->r != nullptr) flush(no->r, meio + 1, fim);
  if (no->l != nullptr) flush(no->l, ini, meio);
  no->f0 = min(no->l ? no->l->f0 : ini, no->r ? no->r->f0 : meio + 1);
  no->f1 = min(no->l ? no->l->f1 : inf, no->r ? no->r->f1 : inf);
}
long long cot[1000010];
int32_t main() {
  cin >> n;
  root = new node(1, inf);
  vector<pair<long long, pair<long long, long long> > > vet;
  vector<long long> comp;
  comp.push_back(1);
  for (long long i = 1; i <= n; i++) {
    long long l, r;
    long long x;
    cin >> x >> l >> r;
    vet.push_back({x, {l, r}});
    comp.push_back(l);
    comp.push_back(l + 1);
    comp.push_back(r);
    comp.push_back(r + 1);
  }
  sort(comp.begin(), comp.end());
  comp.erase(unique(comp.begin(), comp.end()), comp.end());
  for (auto &e : comp) {
    cot[lower_bound(comp.begin(), comp.end(), e) - comp.begin() + 1] = e;
  }
  for (auto &e : vet) {
    e.second.first = lower_bound(comp.begin(), comp.end(), e.second.first) -
                     comp.begin() + 1;
    e.second.second = lower_bound(comp.begin(), comp.end(), e.second.second) -
                      comp.begin() + 1;
  }
  for (auto &e : vet) {
    long long x = e.first;
    long long l, r;
    l = e.second.first;
    r = e.second.second;
    cin >> x >> l >> r;
    update(root, l, r, x);
    cout << cot[root->f0] << "\n";
  }
  return 0;
}