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;
int n, m, cnt, cc;
struct Ques {
  int opt;
  long long l, r;
} q[200005];
long long g[200005 * 3];
struct node {
  int s, lazy;
} t[200005 << 5];
void down_tag(int p, int l, int r, int z) {
  switch (z) {
    case 1:
      t[p].s = r - l + 1;
      t[p].lazy = 1;
      break;
    case 2:
      t[p].s = 0;
      t[p].lazy = 2;
      break;
    case 3:
      t[p].s = r - l + 1 - t[p].s;
      switch (t[p].lazy) {
        case 0:
          t[p].lazy = 3;
          break;
        case 1:
          t[p].lazy = 2;
          break;
        case 2:
          t[p].lazy = 1;
          break;
        case 3:
          t[p].lazy = 0;
          break;
      }
      break;
  }
}
void down(int p, int l, int r) {
  if (!t[p].lazy) return;
  int mid = (l + r) >> 1;
  down_tag(p + p, l, mid, t[p].lazy);
  down_tag(p + p + 1, mid + 1, r, t[p].lazy);
  t[p].lazy = 0;
}
void change(int p, int l, int r, int x, int y, int z) {
  if (l > y || r < x) return;
  if (x <= l && r <= y) {
    down_tag(p, l, r, z);
    return;
  }
  down(p, l, r);
  int mid = (l + r) >> 1;
  change(p + p, l, mid, x, y, z);
  change(p + p + 1, mid + 1, r, x, y, z);
  t[p].s = t[p + p].s + t[p + p + 1].s;
}
int query(int p, int l, int r) {
  if (l == r) return l;
  down(p, l, r);
  int mid = (l + r) >> 1;
  if (t[p + p].s < (mid - l + 1))
    return query(p + p, l, mid);
  else
    return query(p + p + 1, mid + 1, r);
}
int main() {
  scanf("%d", &m);
  g[++cnt] = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%lld%lld", &q[i].opt, &q[i].l, &q[i].r);
    g[++cnt] = q[i].l;
    g[++cnt] = q[i].r;
    g[++cnt] = q[i].r + 1;
  }
  sort(g + 1, g + cnt + 1);
  cc = unique(g + 1, g + cnt + 1) - g - 1;
  for (int i = 1; i <= m; i++) {
    q[i].l = lower_bound(g + 1, g + cc + 1, q[i].l) - g;
    q[i].r = lower_bound(g + 1, g + cc + 1, q[i].r) - g;
    change(1, 1, cc, q[i].l, q[i].r, q[i].opt);
    printf("%lld\n", g[query(1, 1, cc)]);
  }
  return 0;
}