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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long maxn = 1e6;
const long long mod = 1e9 + 7;
const long double PI = acos((long double)-1);
long long pw(long long a, long long b, long long md = mod) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (a * res) % md;
    }
    a = (a * a) % md;
    b >>= 1;
  }
  return (res);
}
long long n;
long long t[maxn], l[maxn], r[maxn];
vector<long long> vec;
struct segment {
  vector<long long> seg, lazy;
  segment(long long x) : seg(maxn * 4, 0), lazy(maxn * 4, -1) {}
  void shift(long long v, long long l, long long r) {
    if (lazy[v] == -1) return;
    if (lazy[v] == 1) seg[v] = r - l;
    if (lazy[v] == 0) seg[v] = 0;
    if (lazy[v] == 2) seg[v] = r - l - seg[v];
    if (r - l > 1) {
      if (lazy[v] == 2) {
        if (lazy[2 * v] == 2) {
          lazy[2 * v] = -1;
        } else if (lazy[2 * v] == 0) {
          lazy[2 * v] = 1;
        } else if (lazy[2 * v] == 1) {
          lazy[2 * v] = 0;
        } else {
          lazy[2 * v] = 2;
        }
        if (lazy[2 * v + 1] == 2) {
          lazy[2 * v + 1] = -1;
        } else if (lazy[2 * v + 1] == 0) {
          lazy[2 * v + 1] = 1;
        } else if (lazy[2 * v + 1] == 1) {
          lazy[2 * v + 1] = 0;
        } else {
          lazy[2 * v + 1] = 2;
        }
      } else
        lazy[2 * v + 1] = lazy[2 * v] = lazy[v];
    }
    lazy[v] = -1;
  }
  void update(long long x, long long L, long long R, long long v = 1,
              long long l = 1, long long r = maxn) {
    shift(v, l, r);
    if (r <= L or R <= l) return;
    if (L <= l and r <= R) {
      lazy[v] = x;
      shift(v, l, r);
      return;
    }
    long long mid = (l + r) / 2;
    update(x, L, R, 2 * v, l, mid);
    update(x, L, R, 2 * v + 1, mid, r);
    seg[v] = seg[2 * v] + seg[2 * v + 1];
  }
  void solve(long long v = 1, long long l = 1, long long r = maxn) {
    shift(v, l, r);
    if (r - l == 1) {
      cout << vec[l - 1] << '\n';
      return;
    }
    long long mid = (r + l) / 2;
    shift(2 * v, l, mid);
    if (seg[2 * v] == mid - l) {
      solve(2 * v + 1, mid, r);
    } else {
      solve(2 * v, l, mid);
    }
  }
};
segment seg(2);
long long comp(long long x) {
  return (lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++)
    cin >> t[i] >> l[i] >> r[i], vec.push_back(l[i]), vec.push_back(r[i] + 1),
        vec.push_back(r[i]);
  vec.push_back(1);
  vec.push_back(1000000000000000001);
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (long long i = 0; i < n; i++) {
    if (t[i] == 1) {
      seg.update(1, comp(l[i]), comp(r[i] + 1));
    }
    if (t[i] == 2) {
      seg.update(0, comp(l[i]), comp(r[i] + 1));
    }
    if (t[i] == 3) {
      seg.update(2, comp(l[i]), comp(r[i] + 1));
    }
    seg.solve();
  }
  return (0);
}