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>
const long long INF = (long long)1e18 + 123;
const int inf = (int)2e9 + 123;
const int mod = 1e9 + 7;
using namespace std;
int n;
int t[7000011], k[7000011], rev[7000011];
void push(int v, int tl, int tr) {
  if (k[v] == 0 && rev[v] == 0) return;
  if (k[v] == 2)
    t[v] = (tr - tl + 1);
  else if (k[v] == 1)
    t[v] = 0;
  if (rev[v]) t[v] = tr - tl + 1 - t[v];
  if (k[v]) {
    rev[v * 2] = rev[v * 2 + 1] = 0;
    k[v * 2] = k[v * 2 + 1] = k[v];
  }
  if (rev[v]) {
    rev[v * 2] ^= 1;
    rev[v * 2 + 1] ^= 1;
  }
  k[v] = rev[v] = 0;
}
void upd(int l, int r, int x, int v = 1, int tl = 1, int tr = 200012) {
  push(v, tl, tr);
  if (tl > r || tr < l || tl > tr || l > r) return;
  if (tl >= l && tr <= r) {
    if (x <= 2) {
      k[v] = x;
      rev[v] = 0;
    } else
      rev[v] ^= 1;
    push(v, tl, tr);
    return;
  }
  int mid = (tl + tr) / 2;
  upd(l, r, x, v * 2, tl, mid);
  upd(l, r, x, v * 2 + 1, mid + 1, tr);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
int get(int v = 1, int tl = 1, int tr = 200012) {
  push(v, tl, tr);
  if (tl == tr) return tl;
  int mid = (tl + tr) / 2;
  push(v * 2, tl, mid);
  push(v * 2 + 1, mid + 1, tr);
  if (t[v * 2] < mid - tl + 1) {
    return get(v * 2, tl, mid);
  } else
    return get(v * 2 + 1, mid + 1, tr);
}
int q;
map<long long, long long> f;
vector<long long> g;
long long id[200015];
long long type[100011], l[100011], r[100011];
int main() {
  unsigned int FOR;
  asm("rdtsc" : "=A"(FOR));
  srand(FOR);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> type[i] >> l[i] >> r[i];
    g.push_back(l[i]);
    g.push_back(r[i] + 1);
  }
  g.push_back(1);
  sort(g.begin(), g.end());
  int pos = 0;
  for (int i = 0; i < g.size(); i++) {
    if (i == 0 || g[i] != g[i - 1]) {
      f[g[i]] = ++pos;
      id[pos] = g[i];
    }
  }
  for (int i = 1; i <= q; i++) {
    l[i] = f[l[i]];
    r[i] = max(l[i], f[r[i] + 1] - 1);
    if (type[i] == 1) {
      upd(l[i], r[i], 2);
    } else if (type[i] == 2) {
      upd(l[i], r[i], 1);
    } else {
      upd(l[i], r[i], 3);
    }
    cout << id[get()] << endl;
  }
  return 0;
}