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>
bool chkmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
inline long long read() {
  long long x = 0, fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
  return x * fh;
}
int m;
struct node {
  long long l, r, opt;
} p[100005];
int root;
long long tree[1600005];
long long lsh[1600005];
int rs[1600005], ls[1600005], lazy[1600005], cnt;
void pushup(int rt, long long l, long long r, int val) {
  if (val <= 2) {
    tree[rt] = 1ll * (r - l + 1) * (val - 1);
    lazy[rt] = val;
  } else {
    tree[rt] = (r - l + 1 - tree[rt]);
    lazy[rt] = 3 - lazy[rt];
  }
}
void pushdown(int rt, long long l, long long r) {
  pushup(rt << 1, l, ((l + r) >> 1), lazy[rt]);
  pushup(rt << 1 | 1, ((l + r) >> 1) + 1, r, lazy[rt]);
  lazy[rt] = 0;
}
void update(int rt, long long l, long long r, long long L, long long R,
            int val) {
  if (L <= l && r <= R) {
    pushup(rt, l, r, val);
    return;
  }
  if (lazy[rt]) pushdown(rt, l, r);
  if (L <= ((l + r) >> 1)) update(rt << 1, l, ((l + r) >> 1), L, R, val);
  if (R > ((l + r) >> 1)) update(rt << 1 | 1, ((l + r) >> 1) + 1, r, L, R, val);
  tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
}
long long query(int rt, long long l, long long r) {
  if (!tree[rt]) return l;
  if (lazy[rt]) pushdown(rt, l, r);
  long long res = 0;
  if ((((l + r) >> 1) - l + 1) != tree[rt << 1])
    res = query(rt << 1, l, ((l + r) >> 1));
  else
    res = query(rt << 1 | 1, ((l + r) >> 1) + 1, r);
  tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
  return res;
}
int main() {
  m = read();
  long long maxn = 0;
  for (int i = (1), _end_ = (int)(m); i <= _end_; ++i) {
    p[i].opt = read();
    p[i].l = read();
    p[i].r = read();
    chkmax(maxn, p[i].r + 1);
    lsh[++cnt] = p[i].l;
    lsh[++cnt] = p[i].r;
    lsh[++cnt] = p[i].r + 1;
  }
  lsh[++cnt] = 1;
  sort(lsh + 1, lsh + cnt + 1);
  cnt = unique(lsh + 1, lsh + cnt + 1) - lsh - 1;
  for (int i = (1), _end_ = (int)(m); i <= _end_; ++i) {
    p[i].l = lower_bound(lsh + 1, lsh + cnt + 1, p[i].l) - lsh;
    p[i].r = lower_bound(lsh + 1, lsh + cnt + 1, p[i].r) - lsh;
    if (p[i].opt == 1) {
      update(1, 1, cnt, p[i].l, p[i].r, 2);
    } else if (p[i].opt == 2) {
      update(1, 1, cnt, p[i].l, p[i].r, 1);
    } else
      update(1, 1, cnt, p[i].l, p[i].r, 3);
    printf("%I64d\n", lsh[query(1, 1, cnt)]);
  }
  return 0;
}