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;
inline unsigned long long read() {
  register unsigned long long res = 0, f = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  do {
    res = res * 10 + ch - '0';
  } while (isdigit(ch = getchar()));
  return res * f;
}
const int N = 1e6 + 5;
struct node {
  unsigned long long lft, rht;
  mutable bool val;
  inline node(unsigned long long l, unsigned long long r = 0, bool v = 0)
      : lft(l), rht(r), val(v) {}
  inline bool operator<(node a) const { return lft < a.lft; }
};
set<node> s;
inline set<node>::iterator split(unsigned long long pos) {
  set<node>::iterator it = s.lower_bound(node(pos));
  if (it->lft == pos && it != s.end()) return it;
  --it;
  unsigned long long l = it->lft, r = it->rht;
  bool v = it->val;
  s.erase(it);
  s.insert(node(l, pos - 1, v));
  return s.insert(node(pos, r, v)).first;
}
inline void assign(unsigned long long l, unsigned long long r, bool val) {
  set<node>::iterator itr = split(r + 1), itl = split(l);
  s.erase(itl, itr);
  s.insert(node(l, r, val));
}
inline void reverse(unsigned long long l, unsigned long long r) {
  set<node>::iterator itr = split(r + 1), itl = split(l);
  for (register set<node>::iterator it = itl; it != itr; ++it) it->val ^= 1;
}
inline unsigned long long query() {
  for (register set<node>::iterator it = s.begin(); it != s.end(); ++it) {
    if (it->val == 0) return it->lft;
  }
  return -1;
}
int main() {
  int m = read();
  s.insert(node(1, 1e18, 0));
  for (register int i = 1; i <= m; ++i) {
    unsigned long long op = read(), l = read(), r = read();
    if (op == 1)
      assign(l, r, 1);
    else if (op == 2)
      assign(l, r, 0);
    else
      reverse(l, r);
    printf("%lld\n", query());
  }
  return 0;
}