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;
struct hehe {
  unsigned long long l, r;
  mutable bool z;
  inline bool operator<(hehe y) const { return l < y.l; }
};
set<hehe> s;
inline set<hehe>::iterator split(unsigned long long pos) {
  hehe qaq;
  qaq.l = pos;
  qaq.r = 0;
  qaq.z = 0;
  set<hehe>::iterator itp = s.lower_bound(qaq);
  if (itp->l == pos && itp != s.end()) return itp;
  itp--;
  unsigned long long l = itp->l, r = itp->r;
  bool val = itp->z;
  s.erase(itp);
  qaq.l = l;
  qaq.r = pos - 1;
  qaq.z = val;
  s.insert(qaq);
  qaq.l = pos;
  qaq.r = r;
  qaq.z = val;
  set<hehe>::iterator ret = s.insert(qaq).first;
  return ret;
}
inline unsigned long long read() {
  unsigned long long s = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s;
}
inline void rev(unsigned long long l, unsigned long long r) {
  set<hehe>::iterator itr, itl;
  itr = split(r + 1);
  itl = split(l);
  for (set<hehe>::iterator it = itl; it != itr; ++it) it->z ^= 1;
}
inline void fz(unsigned long long l, unsigned long long r,
               unsigned long long val) {
  set<hehe>::iterator itl, itr;
  itr = split(r + 1);
  itl = split(l);
  s.erase(itl, itr);
  hehe qwq;
  qwq.l = l;
  qwq.r = r;
  qwq.z = val;
  s.insert(qwq);
}
inline unsigned long long que() {
  for (set<hehe>::iterator it = s.begin(); it != s.end(); ++it) {
    if (it->z == 0) return it->l;
  }
  return 1000000000000000001llu;
}
signed main() {
  unsigned long long n;
  n = read();
  hehe qwq;
  qwq.l = 1;
  qwq.r = 1000000000000000000llu;
  qwq.z = 0;
  s.insert(qwq);
  while (n--) {
    unsigned long long opt, l, r;
    opt = read();
    l = read();
    r = read();
    if (opt == 1)
      fz(l, r, 1);
    else if (opt == 2)
      fz(l, r, 0);
    else if (opt == 3)
      rev(l, r);
    printf("%lld\n", que());
  }
  return 0;
}