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>
const long long MAXL = 1e18;
struct node {
  int t;
  long long l, r;
} query[(1 << 18) + 10];
int n;
int sum[((1 << 18) << 1) + 10], lazy[((1 << 18) << 1) + 10];
long long ans[(1 << 18) + 10];
std::vector<long long> vec;
int trans[4][4] = {{0, 1, 2, 3}, {1, 1, 2, 2}, {2, 1, 2, 1}, {3, 1, 2, 0}};
void modify(int u, int l, int r, int v) {
  switch (v) {
    case 1:
      sum[u] = r - l + 1;
      break;
    case 2:
      sum[u] = 0;
      break;
    case 3:
      sum[u] = r - l + 1 - sum[u];
      break;
  }
  lazy[u] = trans[lazy[u]][v];
}
void pushdown(int u, int l, int r) {
  if (!lazy[u]) return;
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  modify(ls, l, m, lazy[u]);
  modify(rs, m + 1, r, lazy[u]);
  lazy[u] = 0;
}
void insert(int u, int l, int r, int ql, int qr, int v) {
  if (ql <= l && r <= qr) {
    modify(u, l, r, v);
    return;
  }
  pushdown(u, l, r);
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  if (!(m < ql)) insert(ls, l, m, ql, qr, v);
  if (!(qr < m + 1)) insert(rs, m + 1, r, ql, qr, v);
  sum[u] = sum[ls] + sum[rs];
}
int find(int u, int l, int r) {
  if (l == r) return l;
  pushdown(u, l, r);
  int m = l + r >> 1, ls = u << 1, rs = ls | 1;
  if (sum[ls] != (m - l + 1)) return find(ls, l, m);
  return find(rs, m + 1, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%I64d%I64d", &query[i].t, &query[i].l, &query[i].r);
    ++query[i].r;
    vec.push_back(query[i].l);
    vec.push_back(query[i].r);
  }
  vec.push_back(1);
  vec.push_back(MAXL + 1);
  std::sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0, sz = (int)(vec.size()); i < sz; ++i) {
    ans[i + 1] = vec[i];
  }
  for (int i = (int)(vec.size()) + 1; i <= (1 << 18); ++i) {
    ans[i] = MAXL + 1;
  }
  for (int i = 1; i <= n; ++i) {
    int t = query[i].t;
    int l =
        std::lower_bound(vec.begin(), vec.end(), query[i].l) - vec.begin() + 1;
    int r = std::lower_bound(vec.begin(), vec.end(), query[i].r) - vec.begin();
    insert(1, 1, (1 << 18), l, r, t);
    printf("%I64d\n", ans[find(1, 1, (1 << 18))]);
  }
  return 0;
}