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;
using ll = long long;
inline ll read() {
  ll X = 0;
  bool flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    X = (X << 1) + (X << 3) + ch - '0';
    ch = getchar();
  }
  if (flag) return X;
  return ~(X - 1);
}
inline void print(ll x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
struct node {
  ll l, r;
  mutable int val;
  bool operator<(const node &a) const { return l < a.l; }
  node(ll L, ll R, int Val) : l(L), r(R), val(Val) {}
  node(ll L) : l(L) {}
};
set<node> s;
using si = set<node>::iterator;
inline si split(ll pos) {
  si it = s.lower_bound(node(pos));
  if (it != s.end() && it->l == pos) return it;
  --it;
  ll l = it->l, r = it->r;
  int val = it->val;
  s.erase(it);
  s.insert(node(l, pos - 1, val));
  return s.insert(node(pos, r, val)).first;
}
inline void assign(ll l, ll r, int val) {
  si itr = split(r + 1), itl = split(l);
  s.erase(itl, itr);
  s.insert(node(l, r, val));
}
inline void rever(ll l, ll r) {
  si itr = split(r + 1), itl = split(l);
  for (si it = itl; it != itr; ++it) it->val = !it->val;
}
int n;
int main() {
  n = read();
  s.insert(node(1, 1e19, 0));
  while (n--) {
    ll flag = read(), l = read(), r = read();
    if (flag == 1)
      assign(l, r, 1);
    else if (flag == 2)
      assign(l, r, 0);
    else if (flag == 3)
      rever(l, r);
    for (si it = s.begin(); it != s.end(); ++it)
      if (!it->val) {
        print(it->l), putchar('\n');
        break;
      }
  }
  return 0;
}