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;
long long int t[100003];
long long int L[100003];
long long int R[100003];
long long int st[1200303];
long long int lazy[1200303];
bool flip[1200303];
void do_lazy(long long int node, long long int l, long long int r) {
  if (l != r) {
    if (lazy[node] != 2) {
      lazy[2ll * node] = lazy[node];
      lazy[2ll * node + 1ll] = lazy[node];
      flip[2ll * node] = 0;
      flip[2ll * node + 1ll] = 0;
    }
    if (flip[node]) {
      flip[2ll * node] ^= flip[node];
      flip[2ll * node + 1ll] ^= flip[node];
    }
  }
  if (lazy[node] == 0) {
    st[node] = 0;
  }
  if (lazy[node] == 1) {
    st[node] = r - l + 1ll;
  }
  if (flip[node]) {
    st[node] = r - l + 1ll - st[node];
  }
  lazy[node] = 2;
  flip[node] = 0;
}
void upd(long long int node, long long int l, long long int r, long long int ql,
         long long int qr, long long int type) {
  do_lazy(node, l, r);
  if (l > r || l > qr || r < ql) {
    return;
  }
  if (l >= ql && r <= qr) {
    if (type == 1) {
      lazy[node] = 1;
      flip[node] = 0;
    } else if (type == 2) {
      lazy[node] = 0;
      flip[node] = 0;
    } else {
      flip[node] = 1;
    }
    do_lazy(node, l, r);
    return;
  }
  long long int mid = (l + r) / 2;
  upd(2ll * node, l, mid, ql, qr, type);
  upd(2ll * node + 1ll, mid + 1ll, r, ql, qr, type);
  st[node] = st[2ll * node] + st[2ll * node + 1ll];
}
map<long long int, long long int> id;
map<long long int, long long int> rid;
void query(long long int node, long long int l, long long int r) {
  do_lazy(node, l, r);
  if (st[node] == r - l + 1ll) {
    cout << rid[r] + 1ll << "\n";
    return;
  }
  if (l == r) {
    cout << rid[l] << "\n";
    return;
  }
  long long int mid = (l + r) / 2;
  long long int z = st[2ll * node];
  if (lazy[2ll * node] == 0) {
    z = 0;
  }
  if (lazy[2ll * node] == 1) {
    z = mid - l + 1ll;
  }
  if (flip[2ll * node]) {
    z = mid - l + 1ll - z;
  }
  if (z < mid - l + 1ll) {
    query(2ll * node, l, mid);
  } else {
    query(2ll * node + 1ll, mid + 1ll, r);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  set<long long int> s;
  s.insert(1);
  for (long long int i = 1; i <= n; i++) {
    cin >> t[i] >> L[i] >> R[i];
    s.insert(L[i]);
    s.insert(R[i]);
    s.insert(R[i] + 1ll);
  }
  long long int ctr = 0;
  for (auto it : s) {
    id[it] = ++ctr;
    rid[ctr] = it;
  }
  s.clear();
  for (long long int i = 1; i <= 1200300; i++) {
    lazy[i] = 2;
  }
  for (long long int i = 1; i <= n; i++) {
    upd(1, 1, ctr, id[L[i]], id[R[i]], t[i]);
    query(1, 1, ctr);
  }
}