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 int N = 1e5 + 5;
int t[N], tree[N * 16], lazy[N * 16];
long long l[N], r[N];
vector<long long> vc;
void push_up(int rt) { tree[rt] = tree[rt << 1] + tree[rt << 1 | 1]; }
void push_down(int rt, int l, int r) {
  int m = (l + r) >> 1;
  if (lazy[rt] == 1) {
    lazy[rt << 1] = lazy[rt << 1 | 1] = 1;
    tree[rt << 1] = m - l + 1;
    tree[rt << 1 | 1] = r - m;
  } else if (lazy[rt] == 2) {
    lazy[rt << 1] = lazy[rt << 1 | 1] = 2;
    tree[rt << 1] = tree[rt << 1 | 1] = 0;
  } else if (lazy[rt] == 3) {
    lazy[rt << 1] = 3 - lazy[rt << 1];
    lazy[rt << 1 | 1] = 3 - lazy[rt << 1 | 1];
    tree[rt << 1] = m - l + 1 - tree[rt << 1];
    tree[rt << 1 | 1] = r - m - tree[rt << 1 | 1];
  }
  lazy[rt] = 0;
}
void build(int rt, int l, int r) {
  if (l == r) {
    tree[rt] = 0;
    lazy[rt] = 0;
    return;
  }
  int m = (l + r) >> 1;
  build(rt << 1, l, m);
  build(rt << 1 | 1, m + 1, r);
  push_up(rt);
}
void update(int t, int L, int R, int rt, int l, int r) {
  if (L <= l && r <= R) {
    if (t == 1) {
      tree[rt] = r - l + 1;
      lazy[rt] = 1;
    } else if (t == 2) {
      tree[rt] = 0;
      lazy[rt] = 2;
    } else {
      if (lazy[rt] && l != r) push_down(rt, l, r);
      tree[rt] = r - l + 1 - tree[rt];
      lazy[rt] = 3;
    }
    return;
  }
  if (lazy[rt]) push_down(rt, l, r);
  int m = (l + r) >> 1;
  if (L <= m) update(t, L, R, rt << 1, l, m);
  if (R > m) update(t, L, R, rt << 1 | 1, m + 1, r);
  push_up(rt);
}
int query(int rt, int l, int r) {
  if (l == r) {
    return l;
  }
  if (lazy[rt]) push_down(rt, l, r);
  int m = (l + r) >> 1;
  if (tree[rt << 1] != m - l + 1) return query(rt << 1, l, m);
  return query(rt << 1 | 1, m + 1, r);
}
int main() {
  int n;
  cin >> n;
  vc.push_back(1LL);
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> l[i] >> r[i];
    vc.push_back(l[i]);
    vc.push_back(r[i]);
    vc.push_back(r[i] + 1);
    vc.push_back(l[i] + 1);
  }
  sort(vc.begin(), vc.end());
  vc.erase(unique(vc.begin(), vc.end()), vc.end());
  int m = vc.size();
  build(1, 1, m);
  for (int i = 1; i <= n; i++) {
    int L = lower_bound(vc.begin(), vc.end(), l[i]) - vc.begin() + 1;
    int R = lower_bound(vc.begin(), vc.end(), r[i]) - vc.begin() + 1;
    update(t[i], L, R, 1, 1, m);
    cout << vc[query(1, 1, m) - 1] << endl;
  }
  return 0;
}