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>
long long q_pow(long long x, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = x * ret % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
long long __gcd(long long x, long long y) {
  if (!y) return x;
  return __gcd(y, x % y);
}
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
using namespace std;
const long long INF = 0x3f3f3f3f;
const int maxn = 4e5 + 10;
const double eps = 1e-7;
struct node {
  int l, r;
  long long lazy, sum;
  long long tag;
  int len() { return this->r - this->l + 1; }
};
node tree[maxn * 4 + 555];
long long n, m, _hash[maxn];
long long opt[maxn], le[maxn], ri[maxn];
void push_up(int i) { tree[i].sum = tree[2 * i].sum + tree[i * 2 + 1].sum; }
void push_down(int i) {
  if (tree[i].tag != -1) {
    tree[2 * i].tag = tree[i].tag;
    tree[2 * i + 1].tag = tree[i].tag;
    tree[2 * i].lazy = 0;
    tree[2 * i + 1].lazy = 0;
    if (tree[i].tag == 1) {
      tree[2 * i].sum = tree[2 * i].len();
      tree[2 * i + 1].sum = tree[2 * i + 1].len();
    } else {
      tree[2 * i].sum = tree[2 * i + 1].sum = 0;
    }
    tree[i].tag = -1;
  }
  if (tree[i].lazy != 0) {
    if (tree[2 * i].tag != -1)
      tree[2 * i].tag ^= 1;
    else
      tree[2 * i].lazy ^= 1;
    if (tree[2 * i + 1].tag != -1)
      tree[2 * i + 1].tag ^= 1;
    else
      tree[2 * i + 1].lazy ^= 1;
    tree[2 * i].sum = tree[2 * i].len() - tree[2 * i].sum;
    tree[2 * i + 1].sum = tree[2 * i + 1].len() - tree[2 * i + 1].sum;
    tree[i].lazy = 0;
  }
}
void build(int i, int l, int r) {
  tree[i].l = l, tree[i].r = r;
  tree[i].lazy = 0;
  if (l == r) {
    tree[i].sum = 0;
    tree[i].tag = -1;
    tree[i].lazy = 0;
    return;
  }
  int mid = l + r >> 1;
  build(2 * i, l, mid);
  build(2 * i + 1, mid + 1, r);
  push_up(i);
}
void update(int i, int l, int r, int val) {
  if (tree[i].l >= l && tree[i].r <= r) {
    if (val == 1) {
      tree[i].sum = tree[i].len();
      tree[i].lazy = 0;
      tree[i].tag = 1;
    } else if (val == 2) {
      tree[i].sum = 0;
      tree[i].lazy = 0;
      tree[i].tag = 0;
    } else {
      if (tree[i].tag != -1)
        tree[i].tag ^= 1;
      else
        tree[i].lazy ^= 1;
      tree[i].sum = tree[i].len() - tree[i].sum;
    }
    return;
  }
  push_down(i);
  int mid = tree[i].l + tree[i].r >> 1;
  if (l <= mid) update(2 * i, l, r, val);
  if (r > mid) update(2 * i + 1, l, r, val);
  push_up(i);
}
long long query(int i, int l, int r) {
  if (tree[i].l == tree[i].r) {
    return tree[i].l;
  }
  push_down(i);
  int mid = tree[i].l + tree[i].r >> 1;
  long long ans = 0;
  if (tree[2 * i].sum < tree[2 * i].len())
    return query(2 * i, l, r);
  else
    return query(2 * i + 1, l, r);
}
signed main(int argc, char *argv[]) {
  if (argc == 2 && strcmp("-debug", argv[1]) == 0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &opt[i], &le[i], &ri[i]);
    _hash[++cnt] = le[i], _hash[++cnt] = ri[i], _hash[++cnt] = ri[i] + 1;
  }
  _hash[++cnt] = 1;
  sort(_hash + 1, _hash + cnt + 1);
  cnt = unique(_hash + 1, _hash + 1 + cnt) - _hash - 1;
  for (int i = 1; i <= n; i++) {
    le[i] = lower_bound(_hash + 1, _hash + 1 + cnt, le[i]) - _hash;
    ri[i] = lower_bound(_hash + 1, _hash + 1 + cnt, ri[i]) - _hash;
  }
  build(1, 1, cnt);
  for (int i = 1; i <= cnt; i++) {
  }
  for (int i = 1; i <= n; i++) {
    update(1, le[i], ri[i], opt[i]);
    printf("%lld\n", _hash[query(1, 1, cnt)]);
  }
  return 0;
}