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 = 1e5 + 5;
long long ll[maxn], rr[maxn];
long long a[maxn << 2];
int w[maxn];
struct Seg {
  int sum[maxn << 4];
  int lazy[maxn << 4];
  int lazy_r[maxn << 4];
  inline void pushup(int rt) { sum[rt] = sum[rt << 1 | 1] + sum[rt << 1]; }
  inline void pushdown(int rt, int len) {
    if (lazy[rt] != -1) {
      sum[rt << 1] = (len - (len >> 1)) * lazy[rt];
      sum[rt << 1 | 1] = (len >> 1) * lazy[rt];
      lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];
      lazy_r[rt << 1 | 1] = lazy_r[rt << 1] = 0;
      lazy[rt] = -1;
    }
    if (lazy_r[rt]) {
      sum[rt << 1] = len - (len >> 1) - sum[rt << 1];
      sum[rt << 1 | 1] = (len >> 1) - sum[rt << 1 | 1];
      lazy_r[rt << 1] = 1 - lazy_r[rt << 1];
      lazy_r[rt << 1 | 1] = 1 - lazy_r[rt << 1 | 1];
      lazy_r[rt] = 0;
    }
  }
  void build(int l, int r, int rt) {
    lazy[rt] = -1;
    lazy_r[rt] = 0;
    if (l == r) {
      sum[rt] = 0;
      return;
    }
    int m = (l + r) >> 1;
    build(l, m, rt << 1);
    build(m + 1, r, rt << 1 | 1);
    pushup(rt);
  }
  void updata(int L, int R, int val, int l, int r, int rt) {
    if (L <= l && r <= R) {
      sum[rt] = (r - l + 1) * val;
      lazy[rt] = val;
      lazy_r[rt] = 0;
      return;
    }
    pushdown(rt, r - l + 1);
    int m = (l + r) >> 1;
    if (m >= L) updata(L, R, val, l, m, rt << 1);
    if (R > m) updata(L, R, val, m + 1, r, rt << 1 | 1);
    pushup(rt);
  }
  void updata_r(int L, int R, int l, int r, int rt) {
    if (L <= l && r <= R) {
      sum[rt] = (r - l + 1) - sum[rt];
      lazy_r[rt] = 1 - lazy_r[rt];
      return;
    }
    pushdown(rt, r - l + 1);
    int m = (l + r) >> 1;
    if (m >= L) updata_r(L, R, l, m, rt << 1);
    if (R > m) updata_r(L, R, m + 1, r, rt << 1 | 1);
    pushup(rt);
  }
  long long query(int l, int r, int rt) {
    if (l == r) {
      return a[l - 1];
    }
    int len = r - l + 1;
    pushdown(rt, len);
    int m = (l + r) >> 1;
    if (sum[rt << 1] < (len - len / 2))
      return query(l, m, rt << 1);
    else
      return query(m + 1, r, rt << 1 | 1);
  }
} seg;
int main() {
  int n;
  scanf("%d", &n);
  int e = 0;
  a[e++] = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d%I64d%I64d", &w[i], &ll[i], &rr[i]);
    a[e++] = ll[i];
    a[e++] = rr[i];
  }
  sort(a, a + e);
  int m = unique(a, a + e) - a;
  int te = m;
  for (int i = 1; i < te; i++) {
    if (a[i - 1] + 1 != a[i]) a[m++] = a[i - 1] + 1;
  }
  sort(a, a + m);
  a[m] = a[m - 1] + 1;
  m++;
  seg.build(1, m, 1);
  int l, r;
  for (int i = 0; i < n; i++) {
    l = lower_bound(a, a + m, ll[i]) - a;
    r = lower_bound(a, a + m, rr[i]) - a;
    l++;
    r++;
    if (w[i] == 1)
      seg.updata(l, r, 1, 1, m, 1);
    else if (w[i] == 2)
      seg.updata(l, r, 0, 1, m, 1);
    else
      seg.updata_r(l, r, 1, m, 1);
    printf("%I64d\n", seg.query(1, m, 1));
  }
}