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;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
struct segtree {
  struct node {
    bool t[2];
    node() {}
    node(bool a, bool b) {
      t[0] = a;
      t[1] = b;
    }
  };
  vector<node> tree;
  vector<int> lazy;
  int n;
  segtree() {}
  segtree(int _n) {
    n = _n + 10;
    tree.resize(4 * n, node(1, 0));
    lazy.resize(4 * n, 0);
  }
  void flush(int no, int i, int j) {
    if (lazy[no]) {
      if (lazy[no] == 1) {
        tree[no].t[0] = 0;
        tree[no].t[1] = 1;
      } else if (lazy[no] == 2) {
        tree[no].t[0] = 1;
        tree[no].t[1] = 0;
      } else {
        swap(tree[no].t[0], tree[no].t[1]);
      }
      if (i != j) {
        int l = no << 1, r = no << 1 | 1;
        if (lazy[no] == 3) {
          if (lazy[l] == 1)
            lazy[l] = 2;
          else if (lazy[l] == 2)
            lazy[l] = 1;
          else if (lazy[l] == 0)
            lazy[l] = 3;
          else
            lazy[l] = 0;
          if (lazy[r] == 1)
            lazy[r] = 2;
          else if (lazy[r] == 2)
            lazy[r] = 1;
          else if (lazy[r] == 0)
            lazy[r] = 3;
          else
            lazy[r] = 0;
        } else {
          lazy[l] = lazy[r] = lazy[no];
        }
      }
    }
    lazy[no] = 0;
  }
  void update(int no, int i, int j, int a, int b, int t) {
    flush(no, i, j);
    if (i > j or i > b or j < a) return;
    if (a <= i and j <= b) {
      lazy[no] = t;
      flush(no, i, j);
      return;
    }
    int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
    update(l, i, mid, a, b, t);
    update(r, mid + 1, j, a, b, t);
    for (int k = 0; k < (2); ++k) tree[no].t[k] = tree[l].t[k] | tree[r].t[k];
  }
  void pushdown(int no, int i, int j) {
    flush(no, i, j);
    if (i == j) return;
    int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
    flush(l, i, mid);
    flush(r, mid + 1, j);
    for (int k = 0; k < (2); ++k) tree[no].t[k] = tree[l].t[k] | tree[r].t[k];
  }
  int get(int no, int i, int j) {
    pushdown(no, i, j);
    if (i == j) return i;
    int mid = (i + j) >> 1, l = no << 1, r = no << 1 | 1;
    if (tree[l].t[0])
      return get(l, i, mid);
    else
      return get(r, mid + 1, j);
  }
};
const int N = 100100;
long long t[N], l[N], r[N];
const long long MX = (long long)1e18 + 1;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int q;
  cin >> q;
  vector<long long> c;
  c.push_back(1);
  c.push_back(MX);
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> l[i] >> r[i];
    c.push_back(l[i]);
    if (l[i] - 1 > 0) c.push_back(l[i] - 1);
    if (l[i] + 1 <= MX) c.push_back(l[i] + 1);
    c.push_back(r[i]);
    if (r[i] - 1 > 0) c.push_back(r[i] - 1);
    if (r[i] + 1 <= MX) c.push_back(r[i] + 1);
  }
  sort(c.begin(), c.end());
  c.erase(unique(c.begin(), c.end()), c.end());
  int n = (int)c.size();
  segtree T(n);
  for (int i = 0; i < q; i++) {
    l[i] = lower_bound(c.begin(), c.end(), l[i]) - c.begin() + 1;
    r[i] = lower_bound(c.begin(), c.end(), r[i]) - c.begin() + 1;
    T.update(1, 1, n, l[i], r[i], t[i]);
    cout << c[T.get(1, 1, n) - 1] << "\n";
  }
}