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 int N = 100010;
struct node {
  long long l, r;
  long long cover;
  long long lazy;
} nodes[N * 4 * 3 * 2];
struct op {
  long long t;
  long long l, r;
} ops[N];
void build(long long l, long long r, long long u) {
  nodes[u].l = l;
  nodes[u].r = r;
  nodes[u].cover = 0;
  nodes[u].lazy = 0;
  if (l + 1 == r) return;
  build(l, (l + r) >> 1, u << 1);
  build((l + r) >> 1, r, u << 1 | 1);
}
void revert(long long u) {
  nodes[u].cover = 2 - nodes[u].cover;
  nodes[u].lazy = 2 - nodes[u].lazy;
}
void pushDown(long long u) {
  if (!nodes[u].lazy) return;
  if (nodes[u].lazy == 1) {
    nodes[u << 1].cover = nodes[u << 1 | 1].cover = nodes[u].cover;
    nodes[u << 1].lazy = nodes[u << 1 | 1].lazy = 1;
    nodes[u].lazy = 0;
  } else {
    revert(u << 1);
    revert(u << 1 | 1);
    nodes[u].lazy = 0;
  }
}
void pushUp(long long u) {
  if (nodes[u << 1].cover == nodes[u << 1 | 1].cover &&
      nodes[u << 1].cover != 1) {
    nodes[u].cover = nodes[u << 1].cover;
  } else {
    nodes[u].cover = 1;
  }
}
void Update(long long l, long long r, long long u, long long c) {
  pushDown(u);
  if (nodes[u].l == l && nodes[u].r == r) {
    nodes[u].cover = c;
    nodes[u].lazy = 1;
    return;
  }
  long long m = (nodes[u].l + nodes[u].r) >> 1;
  if (r <= m) {
    Update(l, r, u << 1, c);
  } else if (l >= m) {
    Update(l, r, u << 1 | 1, c);
  } else {
    Update(l, m, u << 1, c);
    Update(m, r, u << 1 | 1, c);
  }
  pushUp(u);
}
void Revert(long long l, long long r, long long u) {
  pushDown(u);
  if (nodes[u].l == l && nodes[u].r == r) {
    nodes[u].cover = 2 - nodes[u].cover;
    nodes[u].lazy = 2;
    return;
  }
  long long m = (nodes[u].l + nodes[u].r) >> 1;
  if (r <= m) {
    Revert(l, r, u << 1);
  } else if (l >= m) {
    Revert(l, r, u << 1 | 1);
  } else {
    Revert(l, m, u << 1);
    Revert(m, r, u << 1 | 1);
  }
  pushUp(u);
}
long long query(long long u) {
  pushDown(u);
  long long ans;
  if (nodes[u].cover == 0) {
    ans = nodes[u].l;
  } else if (nodes[u].cover == 1) {
    if (nodes[u << 1].cover == 2) {
      ans = query(u << 1 | 1);
    } else {
      ans = query(u << 1);
    }
  } else {
    ans = nodes[u].r;
  }
  pushUp(u);
  return ans;
}
int main() {
  int n;
  cin >> n;
  vector<long long> all;
  all.push_back(1);
  for (int i = 0; i < n; i++) {
    cin >> ops[i].t >> ops[i].l >> ops[i].r;
    all.push_back(ops[i].l);
    all.push_back(ops[i].r);
    all.push_back(ops[i].r + 1);
  }
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  build(1, all.size() + 1, 1);
  for (int i = 0; i < n; i++) {
    int t = ops[i].t;
    int l = lower_bound(all.begin(), all.end(), ops[i].l) - all.begin() + 1;
    int r = lower_bound(all.begin(), all.end(), ops[i].r) - all.begin() + 1;
    if (t == 1) {
      Update(l, r + 1, 1, 2);
    } else if (t == 2) {
      Update(l, r + 1, 1, 0);
    } else {
      Revert(l, r + 1, 1);
    }
    long long ans = query(1);
    printf("%I64d\n", all[ans - 1]);
  }
  return 0;
}