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 long long MAXN = 1e5 + 21, inf = 1e18 + 21, mod = 1e9 + 7;
int n;
long long t[MAXN], l[MAXN], r[MAXN], c[MAXN << 2];
int sum[MAXN << 3], lazy[MAXN << 3];
inline void pushup(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }
inline void pushdown(int l, int r, int rt) {
  if (!lazy[rt]) return;
  int m = (l + r) >> 1;
  if (lazy[rt] < 3) {
    sum[rt << 1] = (2 - lazy[rt]) * (m - l + 1);
    sum[rt << 1 | 1] = (2 - lazy[rt]) * (r - m);
    lazy[rt << 1] = lazy[rt << 1 | 1] = lazy[rt];
  } else {
    sum[rt << 1] = m - l + 1 - sum[rt << 1];
    sum[rt << 1 | 1] = r - m - sum[rt << 1 | 1];
    lazy[rt << 1] = 3 - lazy[rt << 1];
    lazy[rt << 1 | 1] = 3 - lazy[rt << 1 | 1];
  }
  lazy[rt] = 0;
}
int get(int l, int r, int rt) {
  if (l == r) return l;
  pushdown(l, r, rt);
  int m = (l + r) >> 1;
  if (sum[rt << 1] < m - l + 1) return get(l, m, rt << 1);
  return get(m + 1, r, rt << 1 | 1);
}
void update(int L, int R, int on, int l, int r, int rt) {
  if (L <= l && r <= R) {
    if (on < 3) {
      sum[rt] = (2 - on) * (r - l + 1);
      lazy[rt] = on;
    } else {
      sum[rt] = r - l + 1 - sum[rt];
      lazy[rt] = 3 - lazy[rt];
    }
    return;
  }
  pushdown(l, r, rt);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, on, l, m, rt << 1);
  if (R > m) update(L, R, on, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
void solve(int i, int m) {
  l[i] = lower_bound(c + 1, c + 1 + m, l[i]) - c;
  r[i] = lower_bound(c + 1, c + 1 + m, r[i]) - c;
  update(l[i], r[i], t[i], 1, m, 1);
  cout << c[get(1, m, 1)] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> t[i] >> l[i] >> r[i];
  int m = 1;
  c[m] = 1;
  for (int i = 1; i <= n; i++) {
    c[++m] = l[i];
    c[++m] = r[i];
    c[++m] = r[i] + 1;
  }
  sort(c + 1, c + 1 + m);
  m = unique(c + 1, c + 1 + m) - c - 1;
  for (int i = 1; i <= n; i++) solve(i, m);
  return 0;
}