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 int64_t M = 1e9 + 7, N = 1e6 + 5;
int64_t t[2 * N], d[N], qu[N][3], n, h;
void calc(int64_t p, int64_t k) {
  if (d[p] == 0)
    t[p] = t[p << 1] + t[p << 1 | 1];
  else {
    if (d[p] == 1)
      t[p] = k;
    else if (d[p] == 2)
      t[p] = 0;
    else
      t[p] = k - t[p];
  }
}
void apply(int64_t p, int64_t value, int64_t k) {
  if (value == 1)
    t[p] = k;
  else if (value == 2)
    t[p] = 0;
  else
    t[p] = k - t[p];
  if (p < n) {
    if (value == 3)
      d[p] ^= 3;
    else
      d[p] = value;
  }
}
void push(int64_t l, int64_t r) {
  int64_t s = h, k = 1LL << (h - 1);
  for (l += n, r += n - 1; s > 0; --s, k >>= 1) {
    for (int64_t i = l >> s; i <= r >> s; ++i) {
      if (d[i]) {
        apply(i << 1, d[i], k);
        apply(i << 1 | 1, d[i], k);
        d[i] = 0;
      }
    }
  }
}
void update(int64_t l, int64_t r, int64_t value) {
  push(l, l + 1);
  push(r - 1, r);
  bool cl = false, cr = false;
  int64_t k = 1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
    if (cl) calc(l - 1, k);
    if (cr) calc(r, k);
    if (l & 1) apply(l++, value, k), cl = true;
    if (r & 1) apply(--r, value, k), cr = true;
  }
  for (--l; r > 0; l >>= 1, r >>= 1, k <<= 1) {
    if (cl) calc(l, k);
    if (cr && (!cl || l != r)) calc(r, k);
  }
}
int64_t query(int64_t l, int64_t r) {
  push(l, l + 1);
  push(r - 1, r);
  int64_t res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += t[l++];
    if (r & 1) res += t[--r];
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int64_t q;
  cin >> q;
  n = N;
  h = 64 - __builtin_clzll(n);
  set<int64_t> numbers;
  numbers.insert(1);
  for (int64_t i = 0; i < q; i++) {
    cin >> qu[i][0] >> qu[i][1] >> qu[i][2];
    numbers.insert(qu[i][1]);
    numbers.insert(qu[i][2]);
    numbers.insert(qu[i][2] + 1);
  }
  map<int64_t, int64_t> mp, mp2;
  int64_t count = 1;
  for (auto i : numbers) mp[i] = count, mp2[count++] = i;
  for (int64_t i = 0; i < q; i++) {
    update(mp[qu[i][1]] - 1, mp[qu[i][2]], qu[i][0]);
    int64_t lo = 0, hi = n - 1;
    while (lo < hi) {
      int64_t mid = (lo + hi) / 2;
      if (query(lo, mid + 1) < mid - lo + 1)
        hi = mid;
      else
        lo = mid + 1;
    }
    cout << mp2[lo + 1] << "\n";
  }
  return 0;
}