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;
struct v {
  unsigned long long cnt;
  int t;
} it[(1 << 23)];
unsigned long long k = 20;
void fr(unsigned long long i, unsigned long long l, unsigned long long r) {
  if (l + 1 == r) {
    return;
  }
  if (it[i].t == 0) {
    return;
  }
  if (it[i].t == 1) {
    it[i * 2].cnt = (r - l) / 2;
    it[i * 2].t = 1;
    it[i * 2 + 1].cnt = (r - l) / 2;
    it[i * 2 + 1].t = 1;
  } else if (it[i].t == 2) {
    it[i * 2].cnt = 0;
    it[i * 2].t = 2;
    it[i * 2 + 1].cnt = 0;
    it[i * 2 + 1].t = 2;
  } else {
    if (it[i * 2].t == 3) {
      it[i * 2].t = 0;
      it[i * 2].cnt = (r - l) / 2 - it[i * 2].cnt;
    } else if (it[i * 2].t == 2) {
      it[i * 2].t = 1;
      it[i * 2].cnt = (r - l) / 2;
    } else if (it[i * 2].t == 1) {
      it[i * 2].t = 2;
      it[i * 2].cnt = 0;
    } else {
      it[i * 2].t = 3;
      it[i * 2].cnt = (r - l) / 2 - it[i * 2].cnt;
    }
    if (it[i * 2 + 1].t == 3) {
      it[i * 2 + 1].t = 0;
      it[i * 2 + 1].cnt = (r - l) / 2 - it[i * 2 + 1].cnt;
    } else if (it[i * 2 + 1].t == 2) {
      it[i * 2 + 1].t = 1;
      it[i * 2 + 1].cnt = (r - l) / 2;
    } else if (it[i * 2 + 1].t == 1) {
      it[i * 2 + 1].t = 2;
      it[i * 2 + 1].cnt = 0;
    } else {
      it[i * 2 + 1].t = 3;
      it[i * 2 + 1].cnt = (r - l) / 2 - it[i * 2 + 1].cnt;
    }
  }
  it[i].t = 0;
}
unsigned long long first0(unsigned long long ll = 0,
                          unsigned long long rr = (1 << k),
                          unsigned long long ind = 1) {
  fr(ind, ll, rr);
  if (it[ind].cnt == rr - ll) {
    return rr;
  }
  if (ll + 1 == rr) {
    return ll;
  }
  unsigned long long f1 = first0(ll, (ll + rr) / 2, ind * 2);
  if (f1 == (ll + rr) / 2) {
    return first0((ll + rr) / 2, rr, ind * 2 + 1);
  }
  return f1;
}
void ins(unsigned long long l, unsigned long long r, unsigned long long t,
         unsigned long long ll = 0, unsigned long long rr = (1 << k),
         unsigned long long ind = 1) {
  fr(ind, ll, rr);
  if (l <= ll && rr <= r) {
    it[ind].t = t;
    if (t == 1) {
      it[ind].cnt = rr - ll;
    }
    if (t == 2) {
      it[ind].cnt = 0;
    }
    if (t == 3) {
      it[ind].cnt = (rr - ll) - it[ind].cnt;
    }
    return;
  }
  if (rr <= l || r <= ll) {
    return;
  }
  ins(l, r, t, ll, (ll + rr) / 2, ind * 2);
  ins(l, r, t, (ll + rr) / 2, rr, ind * 2 + 1);
  it[ind].cnt = it[ind * 2].cnt + it[ind * 2 + 1].cnt;
}
unsigned long long tq[(1 << 20)], lq[(1 << 20)], rq[(1 << 20)];
vector<unsigned long long> vals;
map<unsigned long long, unsigned long long> comp, revComp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long n;
  cin >> n;
  for (unsigned long long i = 0; i < n; i++) {
    cin >> tq[i] >> lq[i] >> rq[i];
    lq[i]--;
    vals.push_back(lq[i]);
    vals.push_back(rq[i]);
    vals.push_back(rq[i] + 1);
  }
  vals.push_back(0);
  sort(vals.begin(), vals.end());
  unsigned long long cv = 0;
  for (unsigned long long i = 0; i < vals.size(); i++) {
    if (i && vals[i] != vals[i - 1]) {
      cv++;
    }
    comp[vals[i]] = cv;
    revComp[cv] = vals[i];
  }
  for (unsigned long long i = 0; i < n; i++) {
    ins(comp[lq[i]], comp[rq[i]], tq[i]);
    cout << revComp[first0()] + 1 << "\n";
  }
  return 0;
}