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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 2e5 + 15;
const unsigned long long num = ULLONG_MAX;
unsigned long long pw[64];
inline void calc() {
  pw[0] = 1;
  for (int i = 1; i < 64; ++i) {
    pw[i] = pw[i - 1] << 1;
  }
}
unsigned long long ar[N / 64 + 1];
void Set(int l, int r) {
  for (int i = l; i <= r;) {
    if (i % 64 == 0 && i + 63 <= r) {
      ar[i / 64] = num;
      i += 64;
      continue;
    }
    ar[i / 64] |= pw[i % 64];
    ++i;
  }
}
void Deset(int l, int r) {
  for (int i = l; i <= r;) {
    if (i % 64 == 0 && i + 63 <= r) {
      ar[i / 64] = 0;
      i += 64;
      continue;
    }
    ar[i / 64] &= (ar[i / 64] ^ pw[i % 64]);
    ++i;
  }
}
void Rever(int l, int r) {
  for (int i = l; i <= r;) {
    if (i % 64 == 0 && i + 63 <= r) {
      ar[i / 64] = ~ar[i / 64];
      i += 64;
      continue;
    }
    ar[i / 64] ^= pw[i % 64];
    ++i;
  }
}
int Find_first() {
  int ans = 0;
  for (int i = 0; i <= N / 64; ++i) {
    if (ar[i] != num) {
      unsigned long long g = ~ar[i];
      return ans + __builtin_ctzll(g);
    }
    ans += 64;
  }
}
void solve() {
  int n;
  cin >> n;
  vector<tuple<int, long long, long long> > v(n);
  map<long long, int> cmp;
  map<int, long long> decmp;
  for (int i = 0; i < n; ++i) {
    long long t, l, r;
    cin >> t >> l >> r;
    --l, --r;
    v[i] = make_tuple(t, l, r + 1);
    ++cmp[l], ++cmp[r + 1];
  }
  int C = 0;
  ++cmp[0];
  for (auto &[a, b] : cmp) b = C++;
  for (auto &[a, b] : cmp) decmp[b] = a;
  for (auto &[a, b, c] : v) b = cmp[b], c = cmp[c];
  calc();
  for (int i = 0; i < n; ++i) {
    long long t, l, r;
    tie(t, l, r) = v[i];
    --r;
    if (t == 1)
      Set(l, r);
    else if (t == 2)
      Deset(l, r);
    else if (t == 3)
      Rever(l, r);
    cout << 1 + decmp[Find_first()] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  while (q--) solve();
}