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;
long long f[8 * 500005], tag[8 * 500005], sz;
void dolazy(long long k, long long l, long long r) {
  if (tag[k] == 0) return;
  if (tag[k] == 1) f[k] = r - l + 1;
  if (tag[k] == 2) f[k] = 0;
  if (tag[k] == 3) f[k] = (r - l + 1) - f[k];
  if (l != r) {
    if (tag[k] <= 2)
      tag[k << 1] = tag[(k << 1) + 1] = tag[k];
    else {
      if (tag[k << 1] <= 2)
        tag[k << 1] = 3 - tag[k << 1];
      else
        tag[k << 1] = 0;
      if (tag[(k << 1) | 1] <= 2)
        tag[(k << 1) | 1] = 3 - tag[(k << 1) | 1];
      else
        tag[(k << 1) | 1] = 0;
    }
  }
  tag[k] = 0;
}
void update(long long k, long long l, long long r, long long L, long long R,
            long long opt) {
  dolazy(k, l, r);
  if (l > R || r < L || l > r) return;
  if (L <= l && r <= R) {
    if (opt == 1) f[k] = r - l + 1;
    if (opt == 2) f[k] = 0;
    if (opt == 3) f[k] = (r - l + 1) - f[k];
    if (l != r) {
      if (opt <= 2)
        tag[k << 1] = tag[(k << 1) | 1] = opt;
      else {
        if (tag[k << 1] <= 2)
          tag[k << 1] = 3 - tag[k << 1];
        else
          tag[k << 1] = 0;
        if (tag[(k << 1) | 1] <= 2)
          tag[(k << 1) | 1] = 3 - tag[(k << 1) | 1];
        else
          tag[(k << 1) | 1] = 0;
      }
    }
    return;
  }
  long long mid = (l + r) >> 1;
  update(k << 1, l, mid, L, R, opt);
  update((k << 1) | 1, mid + 1, r, L, R, opt);
  f[k] = f[k << 1] + f[(k << 1) | 1];
}
long long get(long long k, long long l, long long r) {
  dolazy(k, l, r);
  if (l == r) return l;
  long long mid = (l + r) >> 1;
  dolazy(k << 1, l, mid);
  if (f[k << 1] == (mid - l + 1)) return get((k << 1) | 1, mid + 1, r);
  return get(k << 1, l, mid);
}
long long n, L[500005], R[500005], type[500005], val[500005];
set<long long> ok;
map<long long, long long> pos;
void init() {
  ok.insert(1);
  sz = ok.size();
  long long i = 1;
  for (set<long long>::iterator it = ok.begin(); it != ok.end(); it++) {
    val[i] = *it;
    i++;
  }
  i = 1;
  for (; i <= sz; i++) pos[val[i]] = i;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> type[i] >> L[i] >> R[i];
    ok.insert(L[i]);
    ok.insert(L[i] + 1);
    ok.insert(R[i]);
    ok.insert(R[i] + 1);
  }
  init();
  for (long long i = 1; i <= n; i++) {
    update(1, 1, sz, pos[L[i]], pos[R[i]], type[i]);
    cout << val[get(1, 1, sz)] << endl;
  }
  return 0;
}