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;
map<long long, long long> mp;
long long b[1000010 << 2], n, m, cnt;
struct ask {
  long long l, r, k;
} q[1000010];
struct tree {
  long long l, r, sum, rev, tag;
} t[1000010 << 2];
inline int ls(int x) { return x << 1; }
inline int rs(int x) { return x << 1 | 1; }
inline void push_up(long long x) { t[x].sum = t[ls(x)].sum + t[rs(x)].sum; }
inline void build(long long x, long long l, long long r) {
  t[x].l = l;
  t[x].r = r;
  t[x].tag = -1;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  build(ls(x), l, mid);
  build(rs(x), mid + 1, r);
  push_up(x);
}
inline void solve(long long x, long long k) {
  t[x].sum = (t[x].r - t[x].l + 1) * k;
  t[x].tag = k;
}
inline void push_down(long long x) {
  long long mid = (t[x].l + t[x].r) >> 1;
  if (t[x].tag != -1) {
    t[x * 2].tag = t[x * 2 + 1].tag = t[x].tag;
    t[x * 2].sum = (mid - t[x].l + 1) * t[x].tag;
    t[x * 2 + 1].sum = (t[x].r - mid) * t[x].tag;
    t[x * 2].rev = t[x * 2 + 1].rev = 0;
    t[x].tag = -1;
  }
  if (t[x].rev) {
    t[x * 2].rev ^= 1;
    t[x * 2 + 1].rev ^= 1;
    t[x * 2].sum = (mid - t[x].l + 1) - t[x * 2].sum;
    t[x * 2 + 1].sum = (t[x].r - mid) - t[x * 2 + 1].sum;
    t[x].rev = 0;
  }
}
void update(long long l, long long r, long long x, long long k) {
  push_down(x);
  if (t[x].l == l && t[x].r == r) {
    t[x].sum = (t[x].r - t[x].l + 1) * k;
    t[x].tag = k;
    t[x].rev = 0;
    return;
  }
  long long mid = (t[x].l + t[x].r) >> 1;
  if (l > mid) {
    update(l, r, x * 2 + 1, k);
  } else if (r <= mid) {
    update(l, r, x * 2, k);
  } else {
    update(l, mid, x * 2, k);
    update(mid + 1, r, x * 2 + 1, k);
  }
  t[x].sum = t[x * 2].sum + t[x * 2 + 1].sum;
}
void serve(long long l, long long r, long long x) {
  push_down(x);
  if (t[x].l == l && t[x].r == r) {
    t[x].sum = (t[x].r - t[x].l + 1) - t[x].sum;
    t[x].rev ^= 1;
    return;
  }
  long long mid = (t[x].l + t[x].r) >> 1;
  if (l > mid)
    serve(l, r, x * 2 + 1);
  else if (r <= mid)
    serve(l, r, x * 2);
  else {
    serve(l, mid, x * 2);
    serve(mid + 1, r, x * 2 + 1);
  }
  t[x].sum = t[x * 2].sum + t[x * 2 + 1].sum;
}
void check(long long x) {
  if (t[x].l == t[x].r) {
    printf("%I64d\n", b[t[x].l]);
    return;
  }
  long long mid = (t[x].l + t[x].r) >> 1;
  push_down(x);
  if (t[x * 2].sum < mid - t[x].l + 1)
    check(x * 2);
  else
    return check(x * 2 + 1);
}
int main() {
  scanf("%I64d", &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d%I64d%I64d", &q[i].k, &q[i].l, &q[i].r);
    q[i].r++;
    b[++cnt] = q[i].l;
    b[++cnt] = q[i].r;
  }
  b[++cnt] = 1;
  sort(b + 1, b + 1 + cnt);
  n = unique(b + 1, b + 1 + cnt) - (b + 1);
  for (long long i = 1; i <= n; i++) {
    mp[b[i]] = i;
  }
  build(1, 1, n);
  for (long long i = 1; i <= m; i++) {
    if (q[i].k == 1) {
      update(mp[q[i].l], mp[q[i].r] - 1, 1, 1);
    } else if (q[i].k == 2) {
      update(mp[q[i].l], mp[q[i].r] - 1, 1, 0);
    } else {
      serve(mp[q[i].l], mp[q[i].r] - 1, 1);
    }
    check(1);
  }
  return 0;
}