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;
struct Node {
  long long val = 0, acum = 0, siz = 0;
  void atualize(int x) {
    if (x == 0) return;
    if (x < 3) {
      acum = x;
      val = (x == 2 ? 0 : x) * siz;
    } else {
      acum = 3 - acum;
      if (acum == 3 || acum == 0)
        val = siz - val;
      else
        val = (acum == 2 ? 0 : acum) * siz;
    }
  }
  void shift(Node& left, Node& right) {
    left.atualize(acum);
    right.atualize(acum);
    acum = 0;
  }
  void _merge(Node& left, Node& right) { val = left.val + right.val; }
} seg[4 * 330000];
void build(int id, int ini, int fim) {
  seg[id].siz = fim - ini + 1;
  if (ini == fim) return;
  int meio = (ini + fim) / 2;
  build(2 * id, ini, meio);
  build(2 * id + 1, meio + 1, fim);
}
void update(int id, int ini, int fim, int start, int end, int val) {
  if (start > fim || end < ini) return;
  if (ini >= start && fim <= end) {
    seg[id].atualize(val);
    return;
  }
  int meio = (ini + fim) / 2;
  seg[id].shift(seg[2 * id], seg[2 * id + 1]);
  update(2 * id, ini, meio, start, end, val);
  update(2 * id + 1, meio + 1, fim, start, end, val);
  seg[id]._merge(seg[2 * id], seg[2 * id + 1]);
}
int query(int id, int ini, int fim) {
  if (ini == fim) return ini;
  int meio = (ini + fim) / 2;
  seg[id].shift(seg[2 * id], seg[2 * id + 1]);
  if (seg[2 * id].val != seg[2 * id].siz) return query(2 * id, ini, meio);
  return query(2 * id + 1, meio + 1, fim);
}
int n;
long long t[330000], l[330000], r[330000];
set<long long> vals;
map<long long, long long> pos, inv;
int main() {
  build(1, 1, 330000);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &t[i], &l[i], &r[i]);
    vals.insert(l[i]);
    vals.insert(r[i]);
    vals.insert(r[i] + 1);
  }
  vals.insert(1);
  int cnt = 1;
  for (auto v : vals) {
    pos[v] = cnt;
    inv[cnt++] = v;
  }
  for (int i = 0; i < n; i++) {
    l[i] = pos[l[i]];
    r[i] = pos[r[i]];
  }
  for (int i = 0; i < n; i++) {
    if (t[i] == 1)
      update(1, 1, 330000, l[i], r[i], 1);
    else if (t[i] == 2)
      update(1, 1, 330000, l[i], r[i], 2);
    else
      update(1, 1, 330000, l[i], r[i], 3);
    printf("%lld\n", inv[query(1, 1, 330000)]);
  }
  return 0;
}