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 maxn = 2e5 + 10;
vector<long long> v;
int n, sum[maxn * 4], lazy[maxn * 4];
map<long long, bool> mp;
pair<int, pair<long long, long long> > q[maxn];
void put(int s, int e, int id, int x) {
  if (x == 3) {
    if (lazy[id] == 1) {
      lazy[id] = 2;
      sum[id] = 0;
    } else if (lazy[id] == 2) {
      lazy[id] = 1;
      sum[id] = e - s;
    } else if (lazy[id] == 3) {
      lazy[id] = 0;
      sum[id] = (e - s) - sum[id];
    } else {
      lazy[id] = 3;
      sum[id] = ((e - s) - sum[id]);
    }
  } else {
    if (x == 2) {
      lazy[id] = 2;
      sum[id] = 0;
    } else if (x == 1) {
      lazy[id] = 1;
      sum[id] = e - s;
    }
  }
}
void shift(int s, int e, int id) {
  int mid = (s + e) / 2;
  put(s, mid, id << 1, lazy[id]);
  put(mid, e, id << 1 | 1, lazy[id]);
  lazy[id] = 0;
}
void update(int l, int r, int x, int id = 1, int s = 0, int e = v.size()) {
  if (e <= l || r <= s) return;
  if (l <= s && e <= r) {
    put(s, e, id, x);
    return;
  }
  shift(s, e, id);
  int mid = (s + e) / 2;
  update(l, r, x, id << 1, s, mid);
  update(l, r, x, id << 1 | 1, mid, e);
  sum[id] = sum[id << 1] + sum[id << 1 | 1];
}
int get(int id = 1, int s = 0, int e = v.size()) {
  if (sum[id] == e - s) {
    return -1;
  }
  if (s + 1 == e) {
    return s;
  }
  shift(s, e, id);
  int mid = (s + e) / 2;
  int ans = get(id << 1, s, mid);
  if (ans == -1)
    return get(id << 1 | 1, mid, e);
  else
    return ans;
}
void get2(int id = 1, int s = 0, int e = v.size()) {
  if (s + 1 == e) {
    return;
  }
  shift(s, e, id);
  int mid = (s + e) / 2;
  get2(id << 1, s, mid);
  get2(id << 1 | 1, mid, e);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  mp[1] = 1;
  v.push_back(1);
  mp[1e18 + 1] = 1;
  v.push_back(1e18 + 1);
  long long l1, r1;
  for (int a, i = 0; i < n; i++) {
    cin >> a >> l1 >> r1;
    r1++;
    if (mp[l1] == 0) {
      v.push_back(l1);
      mp[l1] = 1;
    }
    if (mp[r1] == 0) {
      v.push_back(r1);
      mp[r1] = 1;
    }
    q[i] = make_pair(a, make_pair(l1, r1));
  }
  sort(v.begin(), v.end());
  pair<long long, long long> p;
  for (int i = 0; i < n; i++) {
    p = q[i].second;
    update(lower_bound(v.begin(), v.end(), p.first) - v.begin(),
           lower_bound(v.begin(), v.end(), p.second) - v.begin(), q[i].first);
    cout << v[get()] << endl;
  }
  return 0;
}