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;
int n;
int t[100005];
long long l[100005], r[100005];
vector<long long> Val;
int ST[800005], Lazy[800005];
void Push(int node, int l, int r) {
  if (Lazy[node] == -1) {
    return;
  }
  if (Lazy[node] == 2) {
    ST[node] = (r - l + 1) - ST[node];
  } else {
    ST[node] = Lazy[node] * (r - l + 1);
  }
  if (l != r) {
    if (Lazy[node] == 2) {
      if (Lazy[node << 1] == -1) {
        Lazy[node << 1] = 2;
      } else if (Lazy[node << 1] != 2) {
        Lazy[node << 1] ^= 1;
      } else {
        Lazy[node << 1] = -1;
      }
      if (Lazy[node << 1 | 1] == -1) {
        Lazy[node << 1 | 1] = 2;
      } else if (Lazy[node << 1 | 1] != 2) {
        Lazy[node << 1 | 1] ^= 1;
      } else {
        Lazy[node << 1 | 1] = -1;
      }
    } else {
      Lazy[node << 1] = Lazy[node];
      Lazy[node << 1 | 1] = Lazy[node];
    }
  }
  Lazy[node] = -1;
}
void Update(int node, int l, int r, int L, int R, int type) {
  Push(node, l, r);
  if (l > R or r < L) {
    return;
  }
  if (L <= l and r <= R) {
    Lazy[node] = type;
    Push(node, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  Update(node << 1, l, mid, L, R, type);
  Update(node << 1 | 1, mid + 1, r, L, R, type);
  ST[node] = ST[node << 1] + ST[node << 1 | 1];
}
long long Get(int node, int l, int r) {
  if (l == r) {
    return Val[l];
  }
  int mid = (l + r) >> 1;
  Push(node << 1, l, mid);
  Push(node << 1 | 1, mid + 1, r);
  if (ST[node << 1] == mid - l + 1) {
    return Get(node << 1 | 1, mid + 1, r);
  }
  return Get(node << 1, l, mid);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i <= 600000; i++) {
    Lazy[i] = -1;
  }
  cin >> n;
  Val.emplace_back(1);
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> l[i] >> r[i];
    t[i]--;
    if (t[i] != 2) {
      t[i] ^= 1;
    }
    Val.emplace_back(l[i]);
    Val.emplace_back(r[i] + 1);
  }
  sort(Val.begin(), Val.end());
  Val.erase(unique(Val.begin(), Val.end()), Val.end());
  for (int i = 1; i <= n; i++) {
    Update(1, 0, Val.size(),
           lower_bound(Val.begin(), Val.end(), l[i]) - Val.begin(),
           upper_bound(Val.begin(), Val.end(), r[i]) - Val.begin() - 1, t[i]);
    cout << Get(1, 0, Val.size()) << '\n';
  }
}