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;
int seg[2 * (1 << 18)], segFlip[2 * (1 << 18)], l[2 * (1 << 18)],
    r[2 * (1 << 18)], up[2 * (1 << 18)];
void init() {
  for (int i = (1 << 18); i < 2 * (1 << 18); i++) {
    l[i] = r[i] = i - (1 << 18);
    seg[i] = 1000000000, segFlip[i] = i - (1 << 18);
  }
  for (int i = (1 << 18) - 1; i > 0; i--) {
    l[i] = l[2 * i], r[i] = r[2 * i + 1];
    seg[i] = 1000000000, segFlip[i] = l[i];
  }
}
void push(int i) {
  if (up[i]) {
    if (up[i] == 1) {
      seg[i] = l[i], segFlip[i] = 1000000000;
      if (i < (1 << 18)) up[2 * i] = up[2 * i + 1] = 1;
    } else if (up[i] == 2) {
      seg[i] = 1000000000, segFlip[i] = l[i];
      if (i < (1 << 18)) up[2 * i] = up[2 * i + 1] = 2;
    } else {
      swap(seg[i], segFlip[i]);
      if (i < (1 << 18))
        up[2 * i] = 3 - up[2 * i], up[2 * i + 1] = 3 - up[2 * i + 1];
    }
    up[i] = 0;
  }
}
int low, high;
void update(int i, int v) {
  push(i);
  if ((l[i] > high) || (r[i] < low)) return;
  if ((l[i] >= low) && (r[i] <= high)) {
    up[i] = v;
    push(i);
    return;
  }
  update(2 * i, v);
  update(2 * i + 1, v);
  seg[i] = min(seg[2 * i], seg[2 * i + 1]);
  segFlip[i] = min(segFlip[2 * i], segFlip[2 * i + 1]);
}
long long tp[100000], ql[100000], qr[100000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int Q;
  cin >> Q;
  vector<long long> lst;
  for (int i = 0; i < Q; i++) {
    cin >> tp[i] >> ql[i] >> qr[i];
    lst.push_back(ql[i]);
    lst.push_back(qr[i] + 1);
  }
  lst.push_back(1);
  sort(lst.begin(), lst.end());
  lst.resize(distance(lst.begin(), unique(lst.begin(), lst.end())));
  init();
  for (int i = 0; i < Q; i++) {
    ql[i] = lower_bound(lst.begin(), lst.end(), ql[i]) - lst.begin();
    qr[i] = lower_bound(lst.begin(), lst.end(), qr[i] + 1) - lst.begin();
    low = ql[i], high = qr[i] - 1;
    update(1, tp[i]);
    cout << lst[segFlip[1]] << '\n';
  }
}