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;
  int cover;
  int lazy;
} nodes[N * 4 * 3 * 2];
struct op {
  int t;
  long long l, r;
} ops[N];
void build(long long l, long long r, int 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(int u) {
  nodes[u].cover = 2 - nodes[u].cover;
  nodes[u].lazy = 2 - nodes[u].lazy;
}
void pushDown(int 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(int 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, int u, int 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, int 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(int 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;
  scanf("%d", &n);
  set<long long> s;
  s.insert(1);
  for (int i = 0; i < n; i++) {
    scanf("%d %I64d %I64d", &ops[i].t, &ops[i].l, &ops[i].r);
    s.insert(ops[i].l);
    s.insert(ops[i].r);
    s.insert(ops[i].r + 1);
  }
  vector<long long> aux(s.begin(), s.end());
  map<long long, int> dic;
  for (int i = 0; i < s.size(); i++) dic[aux[i]] = i + 1;
  for (int i = 0; i < n; i++) {
    ops[i].l = dic[ops[i].l];
    ops[i].r = dic[ops[i].r];
  }
  build(1, s.size() + 1, 1);
  for (int i = 0; i < n; i++) {
    int t = ops[i].t, l = ops[i].l, r = ops[i].r;
    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", aux[ans - 1]);
  }
  return 0;
}