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;
const long long inf = 0x3f3f3f3f;
const long long maxn = 1e5 + 5;
const long long maxm = maxn * 36;
long long rd() {
  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;
}
long long b[maxn];
long long tot = 0;
long long tag_1[maxm], rev_tag[maxm], sm[maxm];
struct node {
  long long op, l, r;
} que[maxn];
vector<long long> vec;
inline void up(long long x) { sm[x] = sm[x << 1] + sm[x << 1 | 1]; }
inline void sp(long long x, long long l, long long r) {
  long long mid = (l + r) >> 1;
  if (tag_1[x] == 1) {
    sm[x << 1] = mid - l + 1;
    sm[x << 1 | 1] = r - mid;
    tag_1[x << 1] = tag_1[x << 1 | 1] = tag_1[x];
    tag_1[x] = 0;
    rev_tag[x << 1] = rev_tag[x << 1 | 1] = 0;
  } else if (tag_1[x] == -1) {
    sm[x << 1] = sm[x << 1 | 1] = 0;
    tag_1[x << 1] = tag_1[x << 1 | 1] = tag_1[x];
    tag_1[x] = 0;
    rev_tag[x << 1] = rev_tag[x << 1 | 1] = 0;
  }
  if (rev_tag[x]) {
    sm[x << 1] = (mid - l + 1) - sm[x << 1];
    sm[x << 1 | 1] = (r - mid) - sm[x << 1 | 1];
    rev_tag[x << 1] ^= 1;
    rev_tag[x << 1 | 1] ^= 1;
    rev_tag[x] = 0;
  }
}
void upd(long long x, long long l, long long r, long long ql, long long qr,
         long long val) {
  if (l >= ql and r <= qr) {
    if (val == -1) {
      sm[x] = 0;
      tag_1[x] = -1;
      rev_tag[x] = 0;
    } else {
      sm[x] = r - l + 1;
      tag_1[x] = 1;
      rev_tag[x] = 0;
    }
    return;
  }
  sp(x, l, r);
  long long mid = (l + r) >> 1;
  if (ql <= mid) upd(x << 1, l, mid, ql, qr, val);
  if (qr > mid) upd(x << 1 | 1, mid + 1, r, ql, qr, val);
  up(x);
}
void rev(long long x, long long l, long long r, long long ql, long long qr) {
  if (l >= ql and r <= qr) {
    sm[x] = (r - l + 1) - sm[x];
    rev_tag[x] ^= 1;
    return;
  }
  sp(x, l, r);
  long long mid = (l + r) >> 1;
  if (ql <= mid) rev(x << 1, l, mid, ql, qr);
  if (qr > mid) rev(x << 1 | 1, mid + 1, r, ql, qr);
  up(x);
}
long long ask(long long x, long long l, long long r) {
  if (l == r) {
    return l;
  }
  sp(x, l, r);
  long long mid = (l + r) >> 1;
  if (sm[x << 1] != mid - l + 1)
    return ask(x << 1, l, mid);
  else
    return ask(x << 1 | 1, mid + 1, r);
}
signed main() {
  long long q = rd();
  vec.push_back(1);
  for (long long i = 1; i <= q; i++) {
    long long op = rd(), l = rd(), r = rd();
    que[i] = (node){op, l, r};
    vec.push_back(l), vec.push_back(r + 1), vec.push_back(r);
    if (l - 1) vec.push_back(l - 1);
  }
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  long long len = vec.size();
  for (long long i = 1; i <= q; i++) {
    long long xx = lower_bound(vec.begin(), vec.end(), que[i].l) - vec.begin();
    long long yy = lower_bound(vec.begin(), vec.end(), que[i].r) - vec.begin();
    if (que[i].op == 1) {
      upd(1, 0, len - 1, xx, yy, 1);
    } else if (que[i].op == 2) {
      upd(1, 0, len - 1, xx, yy, -1);
    } else {
      rev(1, 0, len - 1, xx, yy);
    }
    cout << vec[ask(1, 0, len - 1)] << '\n';
  }
  return 0;
}