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 = 100003;
int n;
struct Operation {
  char type;
  long long l, r;
} op[MaxN];
long long table[MaxN * 4];
int tot;
struct node {
  char statu;
  char inv_tag;
} T[MaxN * 16];
inline void pushinv(const int& p, const int& l, const int& r) {
  if (T[p].inv_tag) {
    if (T[p].statu != 1) {
      T[p].statu = 2 - T[p].statu;
      T[p].inv_tag = 0;
    } else {
      T[p * 2].inv_tag ^= 1;
      T[p * 2 + 1].inv_tag ^= 1;
      T[p].inv_tag = 0;
    }
  }
}
inline void pushstatu(const int& p, const int& l, const int& r) {
  if (l == r) return;
  if (T[p].statu != 1) {
    T[p * 2].statu = T[p * 2 + 1].statu = T[p].statu;
    T[p * 2].inv_tag = T[p * 2 + 1].inv_tag = 0;
  }
}
void add(int p, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) {
    T[p].statu = 2;
    T[p].inv_tag = 0;
    return;
  }
  pushinv(p, l, r);
  if (T[p].statu == 2) return;
  pushstatu(p, l, r);
  T[p].statu = 1;
  int mid = (l + r) / 2;
  if (ll <= mid) add(p * 2, l, mid, ll, rr);
  if (rr > mid) add(p * 2 + 1, mid + 1, r, ll, rr);
  pushinv(p * 2, l, mid), pushinv(p * 2 + 1, mid + 1, r);
  if (T[p * 2].statu == 2 && T[p * 2 + 1].statu == 2) T[p].statu = 2;
}
inline void add(int l, int r) { add(1, 1, tot, l, r); }
void del(int p, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) {
    T[p].statu = 0;
    T[p].inv_tag = 0;
    return;
  }
  pushinv(p, l, r);
  if (T[p].statu == 0) return;
  pushstatu(p, l, r);
  T[p].statu = 1;
  int mid = (l + r) / 2;
  if (ll <= mid) del(p * 2, l, mid, ll, rr);
  if (rr > mid) del(p * 2 + 1, mid + 1, r, ll, rr);
  pushinv(p * 2, l, mid), pushinv(p * 2 + 1, mid + 1, r);
  if (T[p * 2].statu == 0 && T[p * 2 + 1].statu == 0) T[p].statu = 0;
}
inline void del(int l, int r) { del(1, 1, tot, l, r); }
void inv(int p, int l, int r, int ll, int rr) {
  if (ll <= l && r <= rr) {
    T[p].inv_tag ^= 1;
    return;
  }
  pushinv(p, l, r);
  pushstatu(p, l, r);
  int mid = (l + r) / 2;
  if (ll <= mid) inv(p * 2, l, mid, ll, rr);
  if (rr > mid) inv(p * 2 + 1, mid + 1, r, ll, rr);
  pushinv(p * 2, l, mid), pushinv(p * 2 + 1, mid + 1, r);
  T[p].statu = 1;
  if (T[p * 2].statu == 0 && T[p * 2 + 1].statu == 0) T[p].statu = 0;
  if (T[p * 2].statu == 2 && T[p * 2 + 1].statu == 2) T[p].statu = 2;
}
inline void inv(int l, int r) { inv(1, 1, tot, l, r); }
int query(int p, int l, int r, int ll, int rr) {
  pushinv(p, l, r);
  pushstatu(p, l, r);
  if (T[p].statu == 0) return l;
  if (T[p].statu == 2) return -1;
  int mid = (l + r) / 2;
  pushinv(p * 2, l, mid);
  pushinv(p * 2 + 1, mid + 1, r);
  if (T[p * 2].statu < 2)
    return query(p * 2, l, mid, ll, rr);
  else
    return query(p * 2 + 1, mid + 1, r, ll, rr);
}
inline int query(int l, int r) { return query(1, 1, tot, l, r); }
int main() {
  scanf("%d", &n);
  table[++tot] = 1;
  for (int i = 1; i <= n; ++i) {
    int type;
    long long l, r;
    scanf("%d%I64d%I64d", &type, &l, &r);
    op[i].type = type, op[i].l = l, op[i].r = r + 1;
    table[++tot] = l, table[++tot] = r;
    table[++tot] = l + 1, table[++tot] = r + 1;
  }
  sort(table + 1, table + tot + 1);
  tot = unique(table + 1, table + tot + 1) - table - 1;
  for (int i = 1; i <= n; ++i) {
    op[i].l = (lower_bound(table + 1, table + tot + 1, (op[i].l)) - table);
    op[i].r = (lower_bound(table + 1, table + tot + 1, (op[i].r)) - table);
  }
  for (int i = 1; i <= n; ++i) {
    if (op[i].type == 1) {
      add(op[i].l, op[i].r - 1);
    }
    if (op[i].type == 2) {
      del(op[i].l, op[i].r - 1);
    }
    if (op[i].type == 3) {
      inv(op[i].l, op[i].r - 1);
    }
    printf("%I64d\n", table[query(1, tot)]);
  }
  return 0;
}