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;
map<long long, int> ma;
long long a[300005], q[100005][3], dict[300005];
int n, sum[300005 << 2], top, tag[300005 << 2], tot;
bool rev[300005 << 2];
void push_up(int p) { sum[p] = sum[(p << 1)] + sum[(p << 1 | 1)]; }
void opt1(int p, int l, int r, int k) {
  if (k == -1) return;
  sum[p] = (r - l + 1) * k;
  tag[p] = k;
  rev[p] = 0;
}
void opt2(int p, int l, int r) {
  sum[p] = (r - l + 1) - sum[p];
  if (tag[p] != -1)
    tag[p] = !tag[p];
  else
    rev[p] = !rev[p];
}
void push_down(int p, int l, int r) {
  if (tag[p] == -1 && !rev[p]) return;
  int mid = (l + r) >> 1;
  opt1((p << 1), l, mid, tag[p]);
  opt1((p << 1 | 1), mid + 1, r, tag[p]);
  tag[p] = -1;
  if (rev[p])
    opt2((p << 1), l, mid), opt2((p << 1 | 1), mid + 1, r), rev[p] = false;
}
void update(int nl, int nr, int l, int r, int p, int k) {
  if (nl <= l && r <= nr) {
    opt1(p, l, r, k);
    return;
  }
  push_down(p, l, r);
  int mid = (l + r) >> 1;
  if (nl <= mid) update(nl, nr, l, mid, (p << 1), k);
  if (nr > mid) update(nl, nr, mid + 1, r, (p << 1 | 1), k);
  push_up(p);
}
void update_rev(int nl, int nr, int l, int r, int p) {
  if (nl <= l && r <= nr) {
    opt2(p, l, r);
    return;
  }
  push_down(p, l, r);
  int mid = (l + r) >> 1;
  if (nl <= mid) update_rev(nl, nr, l, mid, (p << 1));
  if (nr > mid) update_rev(nl, nr, mid + 1, r, (p << 1 | 1));
  push_up(p);
}
int query(int p, int l, int r) {
  if (!sum[p]) return l;
  int mid = (l + r) >> 1;
  push_down(p, l, r);
  if (sum[(p << 1)] == mid - l + 1)
    return query((p << 1 | 1), mid + 1, r);
  else
    return query((p << 1), l, mid);
}
int main() {
  memset(tag, -1, sizeof(tag));
  cin >> n;
  a[++top] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &q[i][0], &q[i][1], &q[i][2]);
    a[++top] = q[i][1], a[++top] = q[i][2], a[++top] = q[i][2] + 1;
  }
  sort(a + 1, a + 1 + top);
  for (int i = 1; i <= top; i++) {
    if (a[i] != a[i - 1]) ma[a[i]] = ++tot, dict[tot] = a[i];
  }
  for (int i = 1; i <= n; i++) {
    q[i][1] = ma[q[i][1]];
    q[i][2] = ma[q[i][2]];
    if (q[i][0] == 1)
      update(q[i][1], q[i][2], 1, tot, 1, 1);
    else if (q[i][0] == 2)
      update(q[i][1], q[i][2], 1, tot, 1, 0);
    else if (q[i][0] == 3)
      update_rev(q[i][1], q[i][2], 1, tot, 1);
    printf("%lld\n", dict[query(1, 1, tot)]);
  }
  return 0;
}