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 N = 100005;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0', ch = getchar();
  }
  return x * f;
}
struct oper {
  int op;
  long long l, r;
} q[N];
int n, m;
long long num[N * 3];
int siz[N * 12], lazy[N * 12], rev[N * 12];
void pushdown(int u, int l, int r) {
  int mid = (l + r) >> 1;
  if (lazy[u]) {
    lazy[(u << 1)] = lazy[u];
    lazy[(u << 1 | 1)] = lazy[u];
    rev[(u << 1)] = rev[(u << 1 | 1)] = 0;
    if (lazy[u] == 1) siz[(u << 1)] = mid - l + 1, siz[(u << 1 | 1)] = r - mid;
    if (lazy[u] == 2) siz[(u << 1)] = siz[(u << 1 | 1)] = 0;
    lazy[u] = 0;
  }
  if (rev[u]) {
    siz[(u << 1)] = (mid - l + 1) - siz[(u << 1)];
    siz[(u << 1 | 1)] = r - mid - siz[(u << 1 | 1)];
    if (!lazy[(u << 1)])
      rev[(u << 1)] ^= 1;
    else
      lazy[(u << 1)] = 3 - lazy[(u << 1)];
    if (!lazy[(u << 1 | 1)])
      rev[(u << 1 | 1)] ^= 1;
    else
      lazy[(u << 1 | 1)] = 3 - lazy[(u << 1 | 1)];
    rev[u] = 0;
  }
}
void upd(int u, int l, int r, int st, int ed, int op) {
  if (st <= l && r <= ed) {
    if (l == r) {
      if (op == 1)
        siz[u] = 1;
      else if (op == 2)
        siz[u] = 0;
      else
        siz[u] ^= 1;
      return;
    }
    if (op == 1) {
      lazy[u] = op;
      rev[u] = 0;
      siz[u] = r - l + 1;
    }
    if (op == 2) {
      lazy[u] = op;
      rev[u] = 0;
      siz[u] = 0;
    }
    if (op == 3) {
      siz[u] = (r - l + 1) - siz[u];
      if (!lazy[u])
        rev[u] ^= 1;
      else
        lazy[u] = 3 - lazy[u];
    }
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(u, l, r);
  if (st <= mid) upd((u << 1), l, mid, st, ed, op);
  if (ed > mid) upd((u << 1 | 1), mid + 1, r, st, ed, op);
  siz[u] = siz[(u << 1)] + siz[(u << 1 | 1)];
}
int qry(int u, int l, int r) {
  if (l == r) return l;
  int mid = (l + r) >> 1;
  pushdown(u, l, r);
  if (siz[(u << 1)] < mid - l + 1)
    return qry((u << 1), l, mid);
  else
    return qry((u << 1 | 1), mid + 1, r);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int op = read();
    long long l, r;
    scanf("%lld%lld", &l, &r);
    q[i].op = op;
    q[i].l = l;
    q[i].r = r;
    num[++m] = l;
    num[++m] = r;
    num[++m] = r + 1;
  }
  num[++m] = 1;
  sort(num + 1, num + m + 1);
  m = unique(num + 1, num + m + 1) - num - 1;
  for (int i = 1; i <= n; i++) {
    int op = q[i].op;
    long long l, r;
    l = lower_bound(num + 1, num + m + 1, q[i].l) - num;
    r = lower_bound(num + 1, num + m + 1, q[i].r) - num;
    upd(1, 1, m, l, r, op);
    int ans = qry(1, 1, m);
    printf("%lld\n", num[ans]);
  }
  return 0;
}