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 = 5000010;
const int MAXQ = 100010;
const long long INF = 10000000;
const double PI = acos(-1.0);
struct node {
  int L, R;
  int mark;
  long long cnt;
};
int M;
node X[MAXN];
void clear(int t, long long a, long long b) {
  if (a == b) {
    X[t].mark = 0;
    return;
  }
  if (M == MAXN)
    while (1)
      ;
  if (X[t].L == 0) X[t].L = ++M;
  if (X[t].R == 0) X[t].R = ++M;
  if (X[t].mark == 0) return;
  long long mid = (a + b) / 2;
  if (X[t].mark == 1) {
    X[X[t].L].mark = X[X[t].R].mark = 1;
    X[X[t].L].cnt = mid - a + 1;
    X[X[t].R].cnt = b - (mid + 1) + 1;
  } else if (X[t].mark == 2) {
    X[X[t].L].mark = X[X[t].R].mark = 2;
    X[X[t].L].cnt = X[X[t].R].cnt = 0;
  } else {
    if (X[X[t].L].mark == 1 || X[X[t].L].mark == 2) clear(X[t].L, a, mid);
    if (X[X[t].L].mark == 0) {
      X[X[t].L].mark = 3;
      X[X[t].L].cnt = mid - a + 1 - X[X[t].L].cnt;
    } else {
      X[X[t].L].mark = 0;
      X[X[t].L].cnt = mid - a + 1 - X[X[t].L].cnt;
    }
    if (X[X[t].R].mark == 1 || X[X[t].R].mark == 2) clear(X[t].R, mid + 1, b);
    if (X[X[t].R].mark == 0) {
      X[X[t].R].mark = 3;
      X[X[t].R].cnt = b - (mid + 1) + 1 - X[X[t].R].cnt;
    } else {
      X[X[t].R].mark = 0;
      X[X[t].R].cnt = b - (mid + 1) + 1 - X[X[t].R].cnt;
    }
  }
  X[t].mark = 0;
}
void add(int t, long long a, long long b, long long l, long long r) {
  if (a <= l && r <= b) {
    X[t].mark = 1;
    X[t].cnt = r - l + 1;
    return;
  }
  clear(t, l, r);
  long long mid = (l + r) / 2;
  if (a <= mid && b >= l) add(X[t].L, a, b, l, mid);
  if (a <= r && b >= mid + 1) add(X[t].R, a, b, mid + 1, r);
  X[t].cnt = X[X[t].L].cnt + X[X[t].R].cnt;
}
void del(int t, long long a, long long b, long long l, long long r) {
  if (a <= l && r <= b) {
    X[t].mark = 2;
    X[t].cnt = 0;
    return;
  }
  clear(t, l, r);
  long long mid = (l + r) / 2;
  if (a <= mid && b >= l) del(X[t].L, a, b, l, mid);
  if (a <= r && b >= mid + 1) del(X[t].R, a, b, mid + 1, r);
  X[t].cnt = X[X[t].L].cnt + X[X[t].R].cnt;
}
void rev(int t, long long a, long long b, long long l, long long r) {
  clear(t, l, r);
  if (a <= l && r <= b) {
    X[t].mark = 3;
    X[t].cnt = r - l + 1 - X[t].cnt;
    return;
  }
  long long mid = (l + r) / 2;
  if (a <= mid && b >= l) rev(X[t].L, a, b, l, mid);
  if (a <= r && b >= mid + 1) rev(X[t].R, a, b, mid + 1, r);
  X[t].cnt = X[X[t].L].cnt + X[X[t].R].cnt;
}
long long query(int t, long long l, long long r) {
  if (l == r) return l;
  clear(t, l, r);
  if (X[t].cnt == r - l + 1) return INF + 1;
  long long mid = (l + r) / 2;
  if (X[X[t].L].cnt != mid - l + 1) return query(X[t].L, l, mid);
  return query(X[t].R, mid + 1, r);
}
map<long long, int> SS;
long long A[MAXQ], B[MAXQ], C[MAXQ];
vector<long long> SB;
int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
    SS[B[i]] = SS[B[i] - 1] = SS[B[i] + 1] = 0;
    SS[C[i]] = SS[C[i] - 1] = SS[C[i] + 1] = 0;
  }
  SS[1] = 0;
  SB.push_back(0);
  int MMM = 0;
  for (auto iter = SS.begin(); iter != SS.end(); ++iter) {
    if (iter->first == 0) continue;
    iter->second = ++MMM;
    SB.push_back(iter->first);
  }
  for (int i = 0; i < N; ++i) {
    if (A[i] == 1) {
      add(0, SS[B[i]], SS[C[i]], 1, INF);
    } else if (A[i] == 2) {
      del(0, SS[B[i]], SS[C[i]], 1, INF);
    } else {
      rev(0, SS[B[i]], SS[C[i]], 1, INF);
    }
    cout << SB[query(0, 1, INF)] << endl;
  }
  return 0;
}