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;
#pragma warning(disable : 4996)
const long long PACKS = 400;
long long n, q, t[100009], l[100009], r[100009];
vector<long long> C;
long long H[209000], I[1000];
bool U[1000];
void add(long long L, long long R) {
  long long I1 = L / PACKS, I2 = R / PACKS;
  for (int i = I1 + 1; i < I2; i++) I[i] = 1, U[i] = false;
  long long cnt = 0;
  if (U[I1] == true) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] ^= 1;
    U[I1] = false;
  }
  if (U[I2] == true) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] ^= 1;
    U[I2] = false;
  }
  if (I[I1] == 1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I2] == 1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I1] == -1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I[I2] == -1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I1 == I2) {
    for (int i = L; i < R; i++) H[i] = 1;
  } else {
    for (int i = L; i < (I1 + 1) * PACKS; i++) H[i] = 1;
    for (int i = I2 * PACKS; i < R; i++) H[i] = 1;
  }
  for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I1] = 1;
  else if (cnt == 0)
    I[I1] = -1;
  else
    I[I1] = 0;
  cnt = 0;
  for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I2] = 1;
  else if (cnt == 0)
    I[I2] = -1;
  else
    I[I2] = 0;
  cnt = 0;
}
void remove(long long L, long long R) {
  long long I1 = L / PACKS, I2 = R / PACKS;
  for (int i = I1 + 1; i < I2; i++) I[i] = -1, U[i] = false;
  long long cnt = 0;
  if (U[I1] == true) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] ^= 1;
    U[I1] = false;
  }
  if (U[I2] == true) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] ^= 1;
    U[I2] = false;
  }
  if (I[I1] == 1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I2] == 1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I1] == -1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I[I2] == -1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I1 == I2) {
    for (int i = L; i < R; i++) H[i] = 0;
  } else {
    for (int i = L; i < (I1 + 1) * PACKS; i++) H[i] = 0;
    for (int i = I2 * PACKS; i < R; i++) H[i] = 0;
  }
  for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I1] = 1;
  else if (cnt == 0)
    I[I1] = -1;
  else
    I[I1] = 0;
  cnt = 0;
  for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I2] = 1;
  else if (cnt == 0)
    I[I2] = -1;
  else
    I[I2] = 0;
  cnt = 0;
}
void invert(long long L, long long R) {
  long long I1 = L / PACKS, I2 = R / PACKS;
  for (int i = I1 + 1; i < I2; i++) {
    if (I[i] == 1) {
      I[i] = -1;
      U[i] ^= true;
    } else if (I[i] == -1) {
      I[i] = 1;
      U[i] ^= true;
    } else
      U[i] ^= true;
  }
  long long cnt = 0;
  if (U[I1] == true) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] ^= 1;
    U[I1] = false;
  }
  if (U[I2] == true) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] ^= 1;
    U[I2] = false;
  }
  if (I[I1] == 1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I2] == 1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 1;
  }
  if (I[I1] == -1) {
    for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I[I2] == -1) {
    for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) H[i] = 0;
  }
  if (I1 == I2) {
    for (int i = L; i < R; i++) H[i] ^= 1;
  } else {
    for (int i = L; i < (I1 + 1) * PACKS; i++) H[i] ^= 1;
    for (int i = I2 * PACKS; i < R; i++) H[i] ^= 1;
  }
  for (int i = I1 * PACKS; i < (I1 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I1] = 1;
  else if (cnt == 0)
    I[I1] = -1;
  else
    I[I1] = 0;
  cnt = 0;
  for (int i = I2 * PACKS; i < (I2 + 1) * PACKS; i++) cnt += H[i];
  if (cnt == PACKS)
    I[I2] = 1;
  else if (cnt == 0)
    I[I2] = -1;
  else
    I[I2] = 0;
  cnt = 0;
}
long long query() {
  for (int i = 0; i < (n / PACKS) + 1; i++) {
    if (I[i] != 1) {
      if (I[i] == -1) return i * PACKS;
      for (int j = i * PACKS; j < (i + 1) * PACKS; j++) {
        if (((H[j]) ^ (int)(U[i])) == 0) return j;
      }
    }
  }
  return -1;
}
int main() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    scanf("%lld%lld%lld", &t[i], &l[i], &r[i]);
    r[i]++;
    C.push_back(l[i]);
    C.push_back(r[i]);
  }
  C.push_back(1);
  sort(C.begin(), C.end());
  C.erase(unique(C.begin(), C.end()), C.end());
  n = C.size() + 1;
  for (int i = 0; i < q; i++) {
    int pos1 = lower_bound(C.begin(), C.end(), l[i]) - C.begin();
    l[i] = pos1;
    int pos2 = lower_bound(C.begin(), C.end(), r[i]) - C.begin();
    r[i] = pos2;
  }
  for (int i = 0; i < q; i++) {
    if (t[i] == 1) add(l[i], r[i]);
    if (t[i] == 2) remove(l[i], r[i]);
    if (t[i] == 3) invert(l[i], r[i]);
    printf("%lld\n", C[query()]);
  }
  return 0;
}