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>
#pragma comment(linker, "/STACK:1073741824")
using namespace std;
struct Q {
  long long int t, l, r;
  Q(long long int t, long long int l, long long int r) : t(t), l(l), r(r) {}
};
vector<Q> qv;
vector<long long int> vb;
const int MAXN = 2e5 + 100;
int t[MAXN * 4], up[MAXN * 4];
void push(int v, int L, int R) {
  if (up[v] != -1) {
    int m = (L + R) >> 1;
    if (L < R) {
      if (up[v] == 0 || up[v] == 1)
        up[v * 2] = up[v * 2 + 1] = up[v];
      else {
        if (up[v * 2] == 0 || up[v * 2] == 1)
          up[v * 2] = 1 - up[v * 2];
        else if (up[v * 2] == 2)
          up[v * 2] = -1;
        else
          up[v * 2] = 2;
        if (up[v * 2 + 1] == 0 || up[v * 2 + 1] == 1)
          up[v * 2 + 1] = 1 - up[v * 2 + 1];
        else if (up[v * 2 + 1] == 2)
          up[v * 2 + 1] = -1;
        else
          up[v * 2 + 1] = 2;
      }
    }
    if (up[v] == 0)
      t[v] = R - L + 1;
    else if (up[v] == 1)
      t[v] = 0;
    else
      t[v] = R - L + 1 - t[v];
    up[v] = -1;
  }
}
void update(int l, int r, int x, int v, int L, int R) {
  if (l > R || r < L) return;
  if (l == L && r == R) {
    up[v] = x;
    push(v, L, R);
  } else {
    int m = (L + R) >> 1;
    push(v, L, R);
    push(v * 2, L, m);
    push(v * 2 + 1, m + 1, R);
    update(l, min(m, r), x, v * 2, L, m);
    update(max(l, m + 1), r, x, v * 2 + 1, m + 1, R);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
long long int query(int v, int L, int R) {
  if (L == R) {
    return vb[L];
  } else {
    int m = (L + R) >> 1;
    push(v, L, R);
    push(v * 2, L, m);
    push(v * 2 + 1, m + 1, R);
    if (t[v * 2] < m - L + 1)
      return query(v * 2, L, m);
    else
      return query(v * 2 + 1, m + 1, R);
  }
}
int main() {
#pragma warning(disable : 4996)
  int n;
  scanf("%d", &n);
  memset(up, 255, sizeof(up));
  ;
  for (int i = 0; i < n; i++) {
    long long int t, l, r;
    scanf("%lld%lld%lld", &t, &l, &r);
    qv.push_back(Q(t - 1, l, r));
    vb.push_back(l);
    vb.push_back(r + 1);
  }
  vb.push_back(1);
  sort(vb.begin(), vb.end());
  vb.push_back(vb.back() + 1);
  vb.erase(unique(vb.begin(), vb.end()), vb.end());
  for (int i = 0; i < n; i++) {
    auto l = lower_bound(vb.begin(), vb.end(), qv[i].l),
         r = lower_bound(vb.begin(), vb.end(), qv[i].r);
    if (*r > qv[i].r) r--;
    update(l - vb.begin(), r - vb.begin(), qv[i].t, 1, 0, vb.size() - 1);
    printf("%lld\n", query(1, 0, vb.size() - 1));
  }
  return 0;
}