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 maxn = 200000 + 10;
int n, sum[maxn << 2], cov[maxn << 2], tot;
bool rev[maxn << 2];
long long mp[maxn];
struct Query {
  int op;
  long long l, r;
} q[maxn];
inline void pushup(int rt) { sum[rt] = sum[(rt << 1)] + sum[(rt << 1 | 1)]; }
inline void pushdown(int rt, int len) {
  if (cov[rt] != -1) {
    sum[(rt << 1)] = (len - (len >> 1)) * cov[rt];
    sum[(rt << 1 | 1)] = (len >> 1) * cov[rt];
    cov[(rt << 1)] = cov[(rt << 1 | 1)] = cov[rt];
    rev[rt] = 0;
    cov[rt] = -1;
  }
  if (rev[rt]) {
    sum[(rt << 1)] = (len - (len >> 1)) - sum[(rt << 1)];
    sum[(rt << 1 | 1)] = (len >> 1) - sum[(rt << 1 | 1)];
    if (cov[(rt << 1)] >= 0)
      cov[(rt << 1)] ^= 1;
    else
      rev[(rt << 1)] ^= 1;
    if (cov[(rt << 1 | 1)] >= 0)
      cov[(rt << 1 | 1)] ^= 1;
    else
      rev[(rt << 1 | 1)] ^= 1;
    rev[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  sum[rt] = rev[rt] = 0;
  cov[rt] = -1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(l, mid, (rt << 1));
  build(mid + 1, r, (rt << 1 | 1));
}
void cover(int L, int R, int C, int l, int r, int rt) {
  if (L <= l && r <= R) return sum[rt] = (r - l + 1) * C, cov[rt] = C, void();
  pushdown(rt, r - l + 1);
  int mid = (l + r) >> 1;
  if (L <= mid) cover(L, R, C, l, mid, (rt << 1));
  if (R > mid) cover(L, R, C, mid + 1, r, (rt << 1 | 1));
  pushup(rt);
}
void reverse(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    sum[rt] = (r - l + 1) - sum[rt];
    if (cov[rt] >= 0)
      cov[rt] ^= 1;
    else
      rev[rt] ^= 1;
    return;
  }
  pushdown(rt, r - l + 1);
  int mid = (l + r) >> 1;
  if (L <= mid) reverse(L, R, l, mid, (rt << 1));
  if (R > mid) reverse(L, R, mid + 1, r, (rt << 1 | 1));
  pushup(rt);
}
int query(int l, int r, int rt) {
  if (l == r) return l;
  pushdown(rt, r - l + 1);
  int mid = (l + r) >> 1;
  if (sum[(rt << 1)] == (r - l + 1) - ((r - l + 1) >> 1))
    return query(mid + 1, r, (rt << 1 | 1));
  return query(l, mid, (rt << 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%I64d%I64d", &q[i].op, &q[i].l, &q[i].r);
    mp[++tot] = q[i].l;
    mp[++tot] = q[i].r + 1;
  }
  mp[++tot] = 1;
  sort(mp + 1, mp + tot + 1);
  tot = unique(mp + 1, mp + tot + 1) - mp - 1;
  build(1, tot, 1);
  for (int i = 1; i <= n; i++) {
    q[i].l = lower_bound(mp + 1, mp + tot + 1, q[i].l) - mp;
    q[i].r = lower_bound(mp + 1, mp + tot + 1, q[i].r + 1) - mp - 1;
    if (q[i].op == 1) cover(q[i].l, q[i].r, 1, 1, tot, 1);
    if (q[i].op == 2) cover(q[i].l, q[i].r, 0, 1, tot, 1);
    if (q[i].op == 3) reverse(q[i].l, q[i].r, 1, tot, 1);
    printf("%I64d\n", mp[query(1, tot, 1)]);
  }
  return 0;
}