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 = 100010;
long long ql[maxn], qr[maxn], v[maxn << 2];
int op[maxn], m, n, tot;
struct node {
  int sum, tag, rev;
  node() {
    sum = rev = 0;
    tag = -1;
  }
} t[maxn << 4];
long long read() {
  long long x = 0;
  char c = getchar();
  while (c < 48 || c > 57) c = getchar();
  while (c >= 48 && c <= 57) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return x;
}
void ch1(int o, int l, int r, int val) {
  t[o].sum = val * (r - l + 1);
  t[o].tag = val;
  t[o].rev = 0;
}
void ch2(int o, int l, int r) {
  t[o].sum = r - l + 1 - t[o].sum;
  t[o].rev ^= 1;
}
void pushdown(int o, int l, int r) {
  if (~t[o].tag) {
    ch1((o << 1), l, ((l + r) >> 1), t[o].tag);
    ch1((o << 1 | 1), ((l + r) >> 1) + 1, r, t[o].tag);
    t[o].tag = -1;
  }
  if (t[o].rev) {
    ch2((o << 1), l, ((l + r) >> 1));
    ch2((o << 1 | 1), ((l + r) >> 1) + 1, r);
    t[o].rev = 0;
  }
}
void update(int o, int l, int r, int x, int y, int val) {
  if (x <= l && r <= y) {
    ch1(o, l, r, val);
    return;
  }
  pushdown(o, l, r);
  if (x <= ((l + r) >> 1)) update((o << 1), l, ((l + r) >> 1), x, y, val);
  if (y > ((l + r) >> 1))
    update((o << 1 | 1), ((l + r) >> 1) + 1, r, x, y, val);
  t[o].sum = t[(o << 1)].sum + t[(o << 1 | 1)].sum;
}
void revers(int o, int l, int r, int x, int y) {
  if (x <= l && r <= y) {
    ch2(o, l, r);
    return;
  }
  pushdown(o, l, r);
  if (x <= ((l + r) >> 1)) revers((o << 1), l, ((l + r) >> 1), x, y);
  if (y > ((l + r) >> 1)) revers((o << 1 | 1), ((l + r) >> 1) + 1, r, x, y);
  t[o].sum = t[(o << 1)].sum + t[(o << 1 | 1)].sum;
}
int query(int o, int l, int r) {
  if (l == r) return l;
  pushdown(o, l, r);
  if (t[(o << 1)].sum == ((l + r) >> 1) - l + 1)
    return query((o << 1 | 1), ((l + r) >> 1) + 1, r);
  else
    return query((o << 1), l, ((l + r) >> 1));
}
int main() {
  int i;
  m = read();
  v[++tot] = 1;
  for (i = 1; i <= m; i++) {
    op[i] = read(), ql[i] = read(), qr[i] = read();
    v[++tot] = ql[i], v[++tot] = qr[i], v[++tot] = ql[i] + 1,
    v[++tot] = qr[i] + 1;
  }
  sort(v + 1, v + tot + 1);
  n = unique(v + 1, v + tot + 1) - (v + 1);
  for (i = 1; i <= m; i++) {
    ql[i] = lower_bound(v + 1, v + n + 1, ql[i]) - v;
    qr[i] = lower_bound(v + 1, v + n + 1, qr[i]) - v;
    switch (op[i]) {
      case 1: {
        update(1, 1, n, ql[i], qr[i], 1);
        break;
      }
      case 2: {
        update(1, 1, n, ql[i], qr[i], 0);
        break;
      }
      default:
        revers(1, 1, n, ql[i], qr[i]);
    }
    printf("%lld\n", v[query(1, 1, n)]);
  }
  return 0;
}