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 N = 4e5 + 5;
long long read() {
  long long s = 0;
  char c = getchar(), lc = '+';
  while (c < '0' || '9' < c) lc = c, c = getchar();
  while ('0' <= c && c <= '9') s = s * 10 + c - '0', c = getchar();
  return lc == '-' ? -s : s;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else
    write(x / 10), putchar(x % 10 + '0');
}
void print(long long x = -1, char c = '\n') {
  write(x);
  putchar(c);
}
int cnt = 1;
struct node {
  int len, tot, tag;
  void cov(int x) {
    tot = x ? 0 : len;
    tag = x;
  }
  void rev() {
    tot = len - tot;
    if (tag == -1)
      tag = 2;
    else if (tag <= 1)
      tag ^= 1;
    else
      tag = -1;
  }
} t[N * 4];
void build(int w, int l, int r) {
  t[w] = (node){r - l + 1, r - l + 1, -1};
  if (l == r) return;
  build((w * 2), l, ((l + r) / 2));
  build((w * 2 + 1), ((l + r) / 2) + 1, r);
}
void push_up(int w) { t[w].tot = t[(w * 2)].tot + t[(w * 2 + 1)].tot; }
void push_down(int w) {
  if (t[w].tag < 0) return;
  if (t[w].tag <= 1) t[(w * 2)].cov(t[w].tag), t[(w * 2 + 1)].cov(t[w].tag);
  if (t[w].tag == 2) t[(w * 2)].rev(), t[(w * 2 + 1)].rev();
  t[w].tag = -1;
}
void cover(int w, int l, int r, int ql, int qr, int x) {
  if (qr < l || r < ql) return;
  if (ql <= l && r <= qr) return t[w].cov(x);
  push_down(w);
  cover((w * 2), l, ((l + r) / 2), ql, qr, x);
  cover((w * 2 + 1), ((l + r) / 2) + 1, r, ql, qr, x);
  push_up(w);
}
void rever(int w, int l, int r, int ql, int qr) {
  if (qr < l || r < ql) return;
  if (ql <= l && r <= qr) return t[w].rev();
  push_down(w);
  rever((w * 2), l, ((l + r) / 2), ql, qr);
  rever((w * 2 + 1), ((l + r) / 2) + 1, r, ql, qr);
  push_up(w);
}
int querymex(int w, int l, int r) {
  if (l == r) return l;
  push_down(w);
  if (t[(w * 2)].tot)
    return querymex((w * 2), l, ((l + r) / 2));
  else
    return querymex((w * 2 + 1), ((l + r) / 2) + 1, r);
}
long long opt[N], l[N], r[N], b[N];
signed main(signed Goodbye, char *Wangang[]) {
  (void)Goodbye, (void)Wangang;
  int Q = read(), cnt = 0;
  b[++cnt] = 1;
  for (int i = 1; i <= Q; i++) opt[i] = read(), l[i] = read(), r[i] = read();
  for (int i = 1; i <= Q; i++)
    b[++cnt] = l[i], b[++cnt] = l[i] + 1, b[++cnt] = r[i], b[++cnt] = r[i] + 1;
  sort(b + 1, b + 1 + cnt);
  cnt = unique(b + 1, b + 1 + cnt) - b - 1;
  build(1, 1, cnt);
  for (int i = 1; i <= Q; i++) l[i] = lower_bound(b + 1, b + 1 + cnt, l[i]) - b;
  for (int i = 1; i <= Q; i++) r[i] = lower_bound(b + 1, b + 1 + cnt, r[i]) - b;
  for (int i = 1; i <= Q; i++) {
    if (opt[i] == 1) cover(1, 1, cnt, l[i], r[i], 1);
    if (opt[i] == 2) cover(1, 1, cnt, l[i], r[i], 0);
    if (opt[i] == 3) rever(1, 1, cnt, l[i], r[i]);
    print(b[querymex(1, 1, cnt)]);
  }
  return 0;
}