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 MAX = 6e5 + 9;
int n, tree[(MAX << 2)], lazy[(MAX << 2)];
long long l, r, updVal;
vector<long long> v;
vector<pair<int, pair<long long, long long> > > q;
map<long long, long long> decode, encode;
void build(int low, int high, int pos) {
  if (low == high) {
    tree[pos] = 1;
    return;
  }
  int mid = ((low + high) >> 1);
  build(low, mid, (pos << 1));
  build(mid + 1, high, (pos << 1) + 1);
  tree[pos] = tree[(pos << 1)] + tree[(pos << 1) + 1];
}
void pushLazy(int pos, int val) {
  if (val == 1 || val == 2) {
    lazy[pos] = val;
  } else {
    if (lazy[pos] == 1 || lazy[pos] == 2) {
      lazy[pos] = 3 - lazy[pos];
    } else {
      (lazy[pos] == 3 ? lazy[pos] = 0 : lazy[pos] = 3);
    }
  }
}
void push(int low, int high, int pos) {
  if (lazy[pos]) {
    if (lazy[pos] == 1)
      tree[pos] = 0;
    else if (lazy[pos] == 2)
      tree[pos] = high - low + 1;
    else
      tree[pos] = (high - low + 1) - tree[pos];
    if (low != high) {
      pushLazy((pos << 1), lazy[pos]);
      pushLazy((pos << 1) + 1, lazy[pos]);
    }
    lazy[pos] = 0;
  }
}
int qwr(int low, int high, int pos) {
  push(low, high, pos);
  if (low == high) {
    return low;
  }
  int mid = ((low + high) >> 1);
  push(low, mid, (pos << 1));
  if (tree[(pos << 1)] >= 1) {
    return qwr(low, mid, (pos << 1));
  }
  return qwr(mid + 1, high, (pos << 1) + 1);
}
void upd(int low, int high, int pos) {
  push(low, high, pos);
  if (l > high || r < low) {
    return;
  }
  if (l <= low && r >= high) {
    if (updVal == 1)
      tree[pos] = 0;
    else if (updVal == 2)
      tree[pos] = high - low + 1;
    else
      tree[pos] = (high - low + 1) - tree[pos];
    if (low != high) {
      pushLazy((pos << 1), updVal);
      pushLazy((pos << 1) + 1, updVal);
    }
    return;
  }
  int mid = ((low + high) >> 1);
  upd(low, mid, (pos << 1));
  upd(mid + 1, high, (pos << 1) + 1);
  tree[pos] = tree[(pos << 1)] + tree[(pos << 1) + 1];
}
void print(int low, int high, int pos) {
  push(low, high, pos);
  if (low == high) {
    return;
  }
  int mid = ((low + high) >> 1);
  print(low, mid, (pos << 1));
  print(mid + 1, high, (pos << 1) + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    long long l, r;
    cin >> x >> l >> r;
    q.push_back({x, {l, r}});
    v.push_back(l);
    v.push_back(r);
    long long val = r + 1;
    v.push_back(val);
    val = l + 1;
    v.push_back(val);
    if (r >= 2) {
      val = r - 1;
      v.push_back(val);
    }
    if (l >= 2) {
      val = l - 1;
      v.push_back(val);
    }
  }
  v.push_back(-1);
  v.push_back(1);
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  int sz = v.size() - 1;
  build(1, sz, 1);
  for (int i = 1; i < v.size(); ++i) {
    decode[v[i]] = i;
    encode[i] = v[i];
  }
  for (int i = 0; i < n; ++i) {
    int type = q[i].first;
    l = q[i].second.first;
    r = q[i].second.second;
    l = decode[l];
    r = decode[r];
    updVal = type;
    upd(1, sz, 1);
    int res = qwr(1, sz, 1);
    cout << encode[res] << "\n";
  }
  return 0;
}