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>
inline void read(T &x) {
  x = 0;
  char c = getchar(), f = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = 1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
}
int n;
long long L[100005], R[100005], tn[300005], ut, op[100005];
struct node {
  char fg, rv;
  int sm, ln;
} T[1200005];
inline void allf(int x, int c) {
  T[x].sm = c * T[x].ln, T[x].fg = c, T[x].rv = 0;
}
inline void allr(int x) { T[x].sm = T[x].ln - T[x].sm, T[x].rv ^= 1; }
inline void pushf(int x) {
  if (T[x].fg < 2)
    allf(x << 1, T[x].fg), allf(x << 1 | 1, T[x].fg), T[x].fg = 2;
}
inline void pushr(int x) {
  if (T[x].rv) allr(x << 1), allr(x << 1 | 1), T[x].rv = 0;
}
inline void pushdw(int x) { pushf(x), pushr(x); }
inline void build(int x, int l, int r) {
  T[x] = (node){2, 0, 0, r - l + 1};
  if (l == r) return;
  build(x << 1, l, (l + r) >> 1), build(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
inline void modif(int x, int l, int r, int dl, int dr, int dc) {
  if (l > dr || dl > r)
    return;
  else if (dl <= l && r <= dr)
    return allf(x, dc);
  else
    pushdw(x);
  modif(x << 1, l, (l + r) >> 1, dl, dr, dc),
      modif(x << 1 | 1, ((l + r) >> 1) + 1, r, dl, dr, dc),
      T[x].sm = T[x << 1].sm + T[x << 1 | 1].sm;
}
inline void modir(int x, int l, int r, int dl, int dr) {
  if (l > dr || dl > r)
    return;
  else if (dl <= l && r <= dr)
    return allr(x);
  else
    pushdw(x);
  modir(x << 1, l, (l + r) >> 1, dl, dr),
      modir(x << 1 | 1, ((l + r) >> 1) + 1, r, dl, dr),
      T[x].sm = T[x << 1].sm + T[x << 1 | 1].sm;
}
inline int qry(int x, int l, int r) {
  if (l == r)
    return l;
  else
    pushdw(x);
  if (T[x << 1].sm != ((l + r) >> 1) - l + 1)
    return qry(x << 1, l, (l + r) >> 1);
  else
    return qry(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
int main() {
  read(n), tn[++ut] = 1, tn[++ut] = 1e18;
  for (int i = 1; i <= n; i++) {
    read(op[i]), read(L[i]), read(R[i]);
    tn[++ut] = L[i], tn[++ut] = R[i], tn[++ut] = R[i] + 1;
  }
  sort(tn + 1, tn + ut + 1), ut = unique(tn + 1, tn + ut + 1) - tn - 1,
                             build(1, 1, ut);
  for (int i = 1; i <= n; i++)
    L[i] = lower_bound(tn + 1, tn + ut + 1, L[i]) - tn,
    R[i] = lower_bound(tn + 1, tn + ut + 1, R[i]) - tn;
  for (int i = 1; i <= n; i++, printf("%lld\n", tn[qry(1, 1, ut)]))
    if (op[i] == 3)
      modir(1, 1, ut, L[i], R[i]);
    else
      modif(1, 1, ut, L[i], R[i], 2 - op[i]);
  return 0;
}