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;
long long n, m, seed, vmax, op, x, y, l, r;
bool vis[1005];
inline long long read() {
  long long 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 node {
  long long l, r;
  mutable long long v;
  node(long long ll, long long rr = -1, long long vv = 0)
      : l(ll), r(rr), v(vv) {}
  bool operator<(const node &u) const { return l < u.l; }
};
set<node> se;
set<node>::iterator sp(long long op) {
  set<node>::iterator it = se.lower_bound(node(op));
  if (it != se.end() && it->l == op) return it;
  it--;
  long long ll = it->l, rr = it->r, vv = it->v;
  se.erase(it);
  se.insert(node(ll, op - 1, vv));
  return se.insert(node(op, rr, vv)).first;
}
long long sum;
void ass(long long ll, long long rr, long long vv) {
  set<node>::iterator ir = sp(rr + 1), il = sp(ll), ic = il;
  se.erase(ic, ir);
  se.insert(node(ll, rr, vv));
}
void upd(long long ll, long long rr) {
  set<node>::iterator ir = sp(rr + 1), il = sp(ll);
  for (set<node>::iterator nw = il; nw != ir; ++nw) {
    nw->v = 1 - nw->v;
  }
}
long long qry(long long ll = 1, long long rr = 1e18) {
  set<node>::iterator ir = sp(rr + 1), il = sp(ll);
  for (set<node>::iterator nw = il; nw != ir; ++nw) {
    if (nw->v == 0) return nw->l;
  }
  long long x = 1e18 + 1;
  return rr + 1;
}
signed main() {
  n = read();
  long long x = 1e18;
  se.insert((node){1, x, 0});
  for (long long i = 1, iend = n; i <= iend; ++i) {
    long long op, l, r;
    op = read(), l = read(), r = read();
    if (op == 1) {
      ass(l, r, 1);
    } else if (op == 2) {
      ass(l, r, 0);
    } else {
      upd(l, r);
    }
    printf("%lld\n", qry());
  }
  return 0;
}