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>
#pragma GCC optimize("O3")
using namespace std;
const int H = 1 << 19;
struct Query {
  int t;
  long long l, r;
};
struct State {
  long long one, zero;
  State() {
    one = 1e18 + 7;
    zero = 1e18 + 7;
  }
};
State segtree[H << 1];
int lazy[H << 1];
map<long long, long long> numeration;
map<long long, long long> invert;
void Update(int v) {
  if (!lazy[v]) return;
  if (v >= H) {
    if (lazy[v] == 1) {
      segtree[v].one = min(segtree[v].one, segtree[v].zero);
      segtree[v].zero = 1e18 + 7;
    } else if (lazy[v] == 2) {
      segtree[v].zero = min(segtree[v].zero, segtree[v].one);
      segtree[v].one = 1e18 + 7;
    } else {
      long long temp = segtree[v].zero;
      segtree[v].zero = segtree[v].one;
      segtree[v].one = temp;
    }
  } else {
    if (lazy[v] == 1) {
      segtree[v].one = min(segtree[v].one, segtree[v].zero);
      segtree[v].zero = 1e18 + 7;
      lazy[v * 2] = 1;
      lazy[v * 2 + 1] = 1;
    } else if (lazy[v] == 2) {
      segtree[v].zero = min(segtree[v].one, segtree[v].zero);
      segtree[v].one = 1e18 + 7;
      lazy[v * 2] = 2;
      lazy[v * 2 + 1] = 2;
    } else {
      long long temp = segtree[v].zero;
      segtree[v].zero = segtree[v].one;
      segtree[v].one = temp;
      switch (lazy[v * 2]) {
        case 0:
          lazy[v * 2] = 3;
          break;
        case 1:
          lazy[v * 2] = 2;
          break;
        case 2:
          lazy[v * 2] = 1;
          break;
        case 3:
          lazy[v * 2] = 0;
          break;
      }
      switch (lazy[v * 2 + 1]) {
        case 0:
          lazy[v * 2 + 1] = 3;
          break;
        case 1:
          lazy[v * 2 + 1] = 2;
          break;
        case 2:
          lazy[v * 2 + 1] = 1;
          break;
        case 3:
          lazy[v * 2 + 1] = 0;
          break;
      }
    }
  }
  lazy[v] = 0;
}
void AddRange(int l, int r, int v = 1, int low = H, int high = (H << 1) - 1) {
  Update(v);
  if (l > high || r < low) return;
  if (l == low && r == high) {
    lazy[v] = 1;
    Update(v);
    return;
  }
  int mid = (low + high) / 2;
  AddRange(l, min(r, mid), v * 2, low, mid);
  AddRange(max(l, mid + 1), r, v * 2 + 1, mid + 1, high);
  segtree[v].one = min(segtree[v * 2].one, segtree[v * 2 + 1].one);
  segtree[v].zero = min(segtree[v * 2].zero, segtree[v * 2 + 1].zero);
}
void RemoveRange(int l, int r, int v = 1, int low = H,
                 int high = (H << 1) - 1) {
  Update(v);
  if (l > high || r < low) return;
  if (l == low && r == high) {
    lazy[v] = 2;
    Update(v);
    return;
  }
  int mid = (low + high) / 2;
  RemoveRange(l, min(r, mid), v * 2, low, mid);
  RemoveRange(max(l, mid + 1), r, v * 2 + 1, mid + 1, high);
  segtree[v].one = min(segtree[v * 2].one, segtree[v * 2 + 1].one);
  segtree[v].zero = min(segtree[v * 2].zero, segtree[v * 2 + 1].zero);
}
void SwapRange(int l, int r, int v = 1, int low = H, int high = (H << 1) - 1) {
  Update(v);
  if (l > high || r < low) return;
  if (l == low && r == high) {
    lazy[v] = 3;
    Update(v);
    return;
  }
  int mid = (low + high) / 2;
  SwapRange(l, min(r, mid), v * 2, low, mid);
  SwapRange(max(l, mid + 1), r, v * 2 + 1, mid + 1, high);
  segtree[v].one = min(segtree[v * 2].one, segtree[v * 2 + 1].one);
  segtree[v].zero = min(segtree[v * 2].zero, segtree[v * 2 + 1].zero);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<Query> queries;
  numeration[1] = 0;
  for (long long i = 0; i < n; ++i) {
    Query q;
    cin >> q.t >> q.l >> q.r;
    queries.push_back(q);
    numeration[q.l] = 0;
    numeration[q.r] = 0;
    numeration[q.r + 1] = 0;
  }
  int cnt = 0;
  for (auto& i : numeration) {
    invert[cnt] = i.first;
    i.second = cnt++;
  }
  for (long long i = 0; i < cnt; ++i) {
    segtree[i + H].zero = i;
    segtree[i + H].one = 1e18 + 7;
  }
  for (int i = H - 1; i >= 0; --i) {
    segtree[i].one = min(segtree[i * 2].one, segtree[i * 2 + 1].one);
    segtree[i].zero = min(segtree[i * 2].zero, segtree[i * 2 + 1].zero);
  }
  for (long long i = 0; i < n; ++i) {
    int l = numeration[queries[i].l];
    int r = numeration[queries[i].r];
    if (queries[i].t == 1) {
      AddRange(l + H, r + H);
    } else if (queries[i].t == 2) {
      RemoveRange(l + H, r + H);
    } else {
      SwapRange(l + H, r + H);
    }
    cout << invert[segtree[1].zero] << "\n";
  }
  return 0;
}