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>
T read1() {
  T t = 0;
  char k;
  bool v = 0;
  do (k = getchar()) == '-' && (v = 1);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return v ? -t : t;
}
int v[2400005], s, t, opt[100005];
bool ty[2400005];
long long fr[600005];
map<long long, int> ma;
pair<long long, long long> q[100005];
void down(int d, int l, int r) {
  if (l == r) return;
  int mid = l + r >> 1;
  if (ty[d]) {
    v[d << 1] = mid - l + 1 - v[d << 1];
    ty[d << 1] ^= 1;
    v[d << 1 | 1] = r - mid - v[d << 1 | 1];
    ty[d << 1 | 1] ^= 1;
    ty[d] = 0;
  }
  if (!v[d]) v[d << 1] = v[d << 1 | 1] = 0, ty[d << 1] = ty[d << 1 | 1] = 0;
  if (v[d] == r - l + 1)
    v[d << 1] = mid - l + 1, v[d << 1 | 1] = r - mid,
           ty[d << 1] = ty[d << 1 | 1] = 0;
}
void up(int d) { v[d] = v[d << 1] + v[d << 1 | 1]; }
void add(int l, int r, int lx, int rx, int d) {
  down(d, lx, rx);
  if (l == lx && r == rx) {
    v[d] = r - l + 1;
    ty[d] = 0;
    return;
  }
  int mid = lx + rx >> 1;
  if (r <= mid)
    add(l, r, lx, mid, d << 1);
  else if (mid < l)
    add(l, r, mid + 1, rx, d << 1 | 1);
  else
    add(l, mid, lx, mid, d << 1), add(mid + 1, r, mid + 1, rx, d << 1 | 1);
  up(d);
}
void del(int l, int r, int lx, int rx, int d) {
  down(d, lx, rx);
  if (l == lx && r == rx) {
    v[d] = 0;
    ty[d] = 0;
    return;
  }
  int mid = lx + rx >> 1;
  if (r <= mid)
    del(l, r, lx, mid, d << 1);
  else if (mid < l)
    del(l, r, mid + 1, rx, d << 1 | 1);
  else
    del(l, mid, lx, mid, d << 1), del(mid + 1, r, mid + 1, rx, d << 1 | 1);
  up(d);
}
void rev(int l, int r, int lx, int rx, int d) {
  down(d, lx, rx);
  if (l == lx && r == rx) {
    v[d] = r - l + 1 - v[d];
    ty[d] = 1;
    return;
  }
  int mid = lx + rx >> 1;
  if (r <= mid)
    rev(l, r, lx, mid, d << 1);
  else if (mid < l)
    rev(l, r, mid + 1, rx, d << 1 | 1);
  else
    rev(l, mid, lx, mid, d << 1), rev(mid + 1, r, mid + 1, rx, d << 1 | 1);
  up(d);
}
int query(int l, int r, int d) {
  if (l ^ r)
    down(d, l, r);
  else
    return l;
  int mid = l + r >> 1;
  if (v[d << 1] ^ mid - l + 1) return query(l, mid, d << 1);
  return query(mid + 1, r, d << 1 | 1);
}
int main() {
  s = read1<long long>();
  for (int i = 1; i <= s; ++i) {
    opt[i] = read1<long long>();
    ma[q[i].first = read1<long long>()] = 1;
    ma[q[i].first - 1] = 1;
    ma[q[i].first + 1] = 1;
    ma[q[i].second = read1<long long>()] = 1;
    ma[q[i].second - 1] = 1;
    ma[q[i].second + 1] = 1;
  }
  ma[1] = 1;
  for (auto i = ma.begin(); i != ma.end(); ++i)
    if (i->first) i->second = ++t, fr[t] = i->first;
  for (int i = 1; i <= s; printf("%lld\n", fr[query(1, t, 1)]), ++i)
    if (opt[i] == 1)
      add(ma[q[i].first], ma[q[i].second], 1, t, 1);
    else if (opt[i] == 2)
      del(ma[q[i].first], ma[q[i].second], 1, t, 1);
    else
      rev(ma[q[i].first], ma[q[i].second], 1, t, 1);
  return 0;
}