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 = 8e5 + 10;
struct Opt {
  int a;
  long long b, c;
} o[N];
long long pos[N];
int p;
int tg[N << 3], m0[N << 3], m1[N << 3], L[N << 3], R[N << 3];
void build(int x, int l, int r) {
  L[x] = l, R[x] = r;
  if (l == r) {
    m0[x] = l, m1[x] = (0x3f3f3f3f);
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid), build(x << 1 | 1, mid + 1, r);
  m0[x] = min(m0[x << 1], m0[x << 1 | 1]),
  m1[x] = min(m1[x << 1], m1[x << 1 | 1]);
}
void se(int x, int con) {
  int l = L[x], r = R[x];
  if (con < 3) {
    tg[x] = con;
    if (con == 1)
      m1[x] = l, m0[x] = (0x3f3f3f3f);
    else
      m0[x] = l, m1[x] = (0x3f3f3f3f);
  } else if (tg[x] == 1)
    tg[x] = 2, m0[x] = l, m1[x] = (0x3f3f3f3f);
  else if (tg[x] == 2)
    tg[x] = 1, m1[x] = l, m0[x] = (0x3f3f3f3f);
  else if (tg[x] == 3)
    tg[x] = 0, swap(m0[x], m1[x]);
  else
    tg[x] = con, swap(m0[x], m1[x]);
}
void pud(int x) {
  if (!tg[x]) return;
  se(x << 1, tg[x]), se(x << 1 | 1, tg[x]), tg[x] = 0;
}
void updata(int x, int l, int r, int xl, int xr, int con) {
  pud(x);
  if (xl <= l && r <= xr) {
    se(x, con);
    return;
  }
  int mid = (l + r) >> 1;
  if (xl <= mid) updata(x << 1, l, mid, xl, xr, con);
  if (xr > mid) updata(x << 1 | 1, mid + 1, r, xl, xr, con);
  m0[x] = min(m0[x << 1], m0[x << 1 | 1]),
  m1[x] = min(m1[x << 1], m1[x << 1 | 1]);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, a;
  long long b, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c, o[i] = {a, b, c}, pos[p++] = b, pos[p++] = c;
    if (b != 1) pos[p++] = b - 1;
    pos[p++] = c + 1;
  }
  pos[p++] = 1;
  sort(pos, pos + p), p = unique(pos, pos + p) - pos;
  build(1, 1, p);
  for (int i = 0; i < n; i++) {
    a = o[i].a, b = o[i].b, c = o[i].c;
    b = lower_bound(pos, pos + p, b) - pos,
    c = lower_bound(pos, pos + p, c) - pos, b++, c++;
    updata(1, 1, p, b, c, a);
    if (m0[1] <= p)
      cout << pos[m0[1] - 1] << endl;
    else
      cout << pos[p - 1] + 1 << endl;
  }
  return 0;
}