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;
template <typename T = long long>
inline T read() {
  T s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + ch - 48;
    ch = getchar();
  }
  return s * f;
}
const int N = 4e5 + 5, M = 1e6 + 5, MOD = 1e9 + 7, CM = 998244353,
          INF = 0x3f3f3f3f;
const long long linf = 0x7f7f7f7f7f7f7f7f;
struct SegTree {
  struct Node {
    int l, r;
    int lazy, val;
  } tree[N << 2];
  void pushup(int p) {
    tree[p].val = tree[(p << 1)].val + tree[(p << 1 | 1)].val;
  }
  void pushdown(int p) {
    if (tree[p].lazy != -1) {
      if (tree[p].lazy < 2) {
        tree[(p << 1)].lazy = tree[p].lazy;
        tree[(p << 1 | 1)].lazy = tree[p].lazy;
        tree[(p << 1)].val =
            (tree[(p << 1)].r - tree[(p << 1)].l + 1) * tree[p].lazy;
        tree[(p << 1 | 1)].val =
            (tree[(p << 1 | 1)].r - tree[(p << 1 | 1)].l + 1) * tree[p].lazy;
      } else {
        tree[(p << 1)].lazy = 1 - tree[(p << 1)].lazy;
        tree[(p << 1 | 1)].lazy = 1 - tree[(p << 1 | 1)].lazy;
        tree[(p << 1)].val =
            tree[(p << 1)].r - tree[(p << 1)].l + 1 - tree[(p << 1)].val;
        tree[(p << 1 | 1)].val = tree[(p << 1 | 1)].r - tree[(p << 1 | 1)].l +
                                 1 - tree[(p << 1 | 1)].val;
      }
      tree[p].lazy = -1;
    }
  }
  void build(int p, int l, int r) {
    tree[p].l = l, tree[p].r = r;
    tree[p].lazy = -1;
    tree[p].val = 0;
    if (l == r) {
      return;
    }
    int mid = (l + r) >> 1;
    build((p << 1), l, mid);
    build((p << 1 | 1), mid + 1, r);
    pushup(p);
  }
  int query(int p, int l, int r) {
    if (l <= tree[p].l && tree[p].r <= r) return tree[p].val;
    pushdown(p);
    int mid = (tree[p].l + tree[p].r) >> 1;
    int ans = 0;
    if (l <= mid) ans += query((p << 1), l, r);
    if (r > mid) ans += query((p << 1 | 1), l, r);
    return ans;
  }
  void change(int p, int l, int r, int x) {
    if (l <= tree[p].l && tree[p].r <= r) {
      if (x < 2) {
        tree[p].val = (tree[p].r - tree[p].l + 1) * x;
        tree[p].lazy = x;
      } else {
        tree[p].val = tree[p].r - tree[p].l + 1 - tree[p].val;
        tree[p].lazy = 1 - tree[p].lazy;
      }
      return;
    }
    pushdown(p);
    int mid = (tree[p].l + tree[p].r) >> 1;
    if (l <= mid) change((p << 1), l, r, x);
    if (r > mid) change((p << 1 | 1), l, r, x);
    pushup(p);
  }
} seg;
long long a[N];
int tot;
int cal(int n) {
  int l = 1, r = n;
  while (l + 2 <= r) {
    int mid = (l + r) >> 1;
    if (seg.query(1, 1, mid) == mid)
      l = mid;
    else
      r = mid - 1;
  }
  for (int i = max(l - 3, 1); i <= min(n, r + 3); i++) {
    if (seg.query(1, 1, i) == i - 1) return i;
  }
  return l;
}
struct Operator {
  int op;
  long long l, r;
} q[N];
void solve(int kase) {
  int n = read();
  a[++tot] = 1;
  for (int i = 1; i <= n; i++) {
    q[i].op = read(), q[i].l = read(), q[i].r = read();
    a[++tot] = q[i].l, a[++tot] = q[i].r;
    a[++tot] = q[i].r + 1;
  }
  sort(a + 1, a + tot + 1);
  int qq = unique(a + 1, a + tot + 1) - a - 1;
  for (int i = 1; i <= n; i++) {
    q[i].l = lower_bound(a + 1, a + qq + 1, q[i].l) - a;
    q[i].r = lower_bound(a + 1, a + qq + 1, q[i].r) - a;
  }
  seg.build(1, 1, qq);
  for (int i = 1; i <= n; i++) {
    int op = q[i].op, l = q[i].l, r = q[i].r;
    if (op == 1) seg.change(1, l, r, 1);
    if (op == 2) seg.change(1, l, r, 0);
    if (op == 3) seg.change(1, l, r, 2);
    printf("%lld\n", a[cal(qq)]);
  }
}
const bool ISFILE = 0, DUO = 0;
int main() {
  clock_t start, finish;
  double totaltime;
  start = clock();
  if (ISFILE) freopen("/Users/i/Desktop/practice/in.txt", "r", stdin);
  if (DUO) {
    int Kase = 0;
    cin >> Kase;
    for (int kase = 1; kase <= Kase; kase++) solve(kase);
  } else
    solve(1);
  finish = clock();
  ;
  ;
  return 0;
}