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;
struct SegNode {
  int val, lazy;
  SegNode *right;
  SegNode *left;
  SegNode() {
    val = 0;
    lazy = -1;
    right = left = NULL;
  }
};
inline bool get_val(SegNode *&node) {
  if (node && node->lazy + 1) node->val = node->lazy;
  return (!node || !node->val);
}
void push_lazy(SegNode *&node) {
  if (node->left == NULL) node->left = new SegNode();
  if (node->right == NULL) node->right = new SegNode();
  if (node->lazy == -1) return;
  node->val = node->lazy;
  node->left->lazy = node->lazy;
  node->right->lazy = node->lazy;
  node->lazy = -1;
}
void swap(int i, int j, SegNode *&zero, SegNode *&one, int L = 1, int R = N) {
  if (zero == NULL) zero = new SegNode();
  if (one == NULL) one = new SegNode();
  push_lazy(zero);
  push_lazy(one);
  if (i > R || j < L) return;
  if (L >= i && R <= j) {
    swap(zero, one);
    return;
  }
  int mid = L + R >> 1;
  swap(i, j, zero->left, one->left, L, mid);
  swap(i, j, zero->right, one->right, mid + 1, R);
  one->val = min(one->left->val, one->right->val);
  zero->val = min(zero->left->val, zero->right->val);
}
void update(int i, int j, int val, SegNode *&node, int L = 1, int R = N) {
  if (node == NULL) node = new SegNode();
  push_lazy(node);
  if (R < i || L > j) return;
  if (L >= i && R <= j) {
    node->lazy = val;
    push_lazy(node);
    return;
  }
  int mid = L + R >> 1;
  update(i, j, val, node->left, L, mid);
  update(i, j, val, node->right, mid + 1, R);
  node->val = min(node->left->val, node->right->val);
}
int ans;
void query(SegNode *&node, int L = 1, int R = N) {
  if (node == NULL || L == R) {
    ans = L;
    return;
  }
  if (node) push_lazy(node);
  int mid = L + R >> 1;
  if (get_val(node->left))
    query(node->left, L, mid);
  else
    query(node->right, mid + 1, R);
}
int main() {
  int n;
  scanf("%d", &n);
  map<long long, int> compress;
  vector<tuple<int, long long, long long>> queries;
  for (int i = 0; i < n; i++) {
    long long t, L, R;
    scanf("%lld%lld%lld", &t, &L, &R);
    queries.push_back({t, L, R});
    compress[L];
    compress[L + 1];
    compress[max(1LL, L - 1)];
    compress[R];
    compress[R + 1];
    compress[max(1LL, R - 1)];
  }
  map<int, long long> inv;
  compress[1];
  compress[4e18];
  for (auto &[val, id] : compress) {
    id = ++N;
    inv[N] = val;
  }
  SegNode *one = NULL, *zero = NULL;
  update(1, N, 1, one);
  for (auto &[t, L, R] : queries) {
    L = compress[L], R = compress[R];
    if (t == 1) {
      update(L, R, 1, zero);
      update(L, R, 0, one);
    } else if (t == 2) {
      update(L, R, 0, zero);
      update(L, R, 1, one);
    } else {
      swap(L, R, zero, one);
    }
    query(zero);
    printf("%lld\n", inv[ans]);
  }
  return 0;
}