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>
inline long long read() {
  long long x = 0;
  char ch = getchar(), w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * w;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
using namespace std;
const int N = 6e5 + 666;
long long n;
struct T {
  long long l, r;
  long long tag, mov, add;
  long long v, s;
} t[N * 4];
long long b[N * 3], d[N];
void build(long long o, long long l, long long r) {
  t[o].l = l, t[o].r = r;
  if (l == r) {
    t[o].s = d[l];
    return;
  }
  long long mid = (l + r) >> 1;
  if (l <= mid) build((o << 1), l, mid);
  if (r > mid) build((o << 1 | 1), mid + 1, r);
  t[o].s = t[(o << 1)].s + t[(o << 1 | 1)].s;
}
void up(long long o) { t[o].v = t[(o << 1)].v + t[(o << 1 | 1)].v; }
void chg(long long o) {
  t[o].tag ^= 1;
  t[o].v = t[o].s - t[o].v;
}
void Add(long long o) {
  t[o].tag = 0;
  t[o].add = 1;
  t[o].mov = 0;
  t[o].v = t[o].s;
}
void Mov(long long o) {
  t[o].tag = 0;
  t[o].mov = 1;
  t[o].add = 0;
  t[o].v = 0;
}
void down(long long o) {
  if (t[o].mov) {
    Mov((o << 1));
    Mov((o << 1 | 1));
    t[o].mov = 0;
  }
  if (t[o].add) {
    Add((o << 1));
    Add((o << 1 | 1));
    t[o].add = 0;
  }
  if (t[o].tag) {
    chg((o << 1));
    chg((o << 1 | 1));
    t[o].tag = 0;
  }
}
void turn(long long o, long long l, long long r) {
  if (l <= t[o].l && r >= t[o].r) {
    chg(o);
    return;
  }
  long long mid = (t[o].l + t[o].r) >> 1;
  down(o);
  if (l <= mid) turn((o << 1), l, r);
  if (r > mid) turn((o << 1 | 1), l, r);
  up(o);
}
void ins(long long o, long long l, long long r) {
  if (l <= t[o].l && r >= t[o].r) {
    Mov(o);
    return;
  }
  long long mid = (t[o].l + t[o].r) >> 1;
  down(o);
  if (l <= mid) ins((o << 1), l, r);
  if (r > mid) ins((o << 1 | 1), l, r);
  up(o);
}
void fu(long long o, long long l, long long r) {
  if (l <= t[o].l && r >= t[o].r) {
    Add(o);
    return;
  }
  long long mid = (t[o].l + t[o].r) >> 1;
  down(o);
  if (l <= mid) fu((o << 1), l, r);
  if (r > mid) fu((o << 1 | 1), l, r);
  up(o);
}
long long query(long long o) {
  down(o);
  if (t[o].l == t[o].r) return t[o].l;
  long long mid = (t[o].l + t[o].r) >> 1;
  if (t[(o << 1)].s != t[(o << 1)].v)
    return query((o << 1));
  else
    return query((o << 1 | 1));
}
long long op[N], l[N], r[N];
long long c[N], tot;
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) {
    op[i] = read();
    l[i] = read();
    r[i] = read();
    b[++tot] = l[i];
    b[++tot] = r[i];
  }
  sort(b + 1, b + 1 + tot);
  tot = unique(b + 1, b + 1 + tot) - b - 1;
  long long tmp = 0;
  for (long long i = 1; i <= tot; ++i) {
    if (b[i] - b[i - 1] > 1)
      d[++tmp] = b[i] - b[i - 1] - 1, c[tmp] = b[i - 1] + 1;
    c[++tmp] = b[i];
    d[tmp] = 1;
  }
  d[++tmp] = 1;
  c[tmp] = b[tot] + 1;
  *b = tmp;
  for (long long i = 1; i <= *b; ++i) b[i] = c[i];
  build(1, 1, *b);
  for (long long i = 1; i <= n; ++i) {
    l[i] = lower_bound(b + 1, b + 1 + *b, l[i]) - b;
    r[i] = lower_bound(b + 1, b + 1 + *b, r[i]) - b;
    if (op[i] == 1) fu(1, l[i], r[i]);
    if (op[i] == 2) ins(1, l[i], r[i]);
    if (op[i] == 3) turn(1, l[i], r[i]);
    writeln(b[query(1)]);
  }
  return 0;
}