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 + 123;
struct Q {
  long long l, r, c;
  Q(long long nl = 0, long long nr = 0, long long nc = 0) {
    l = nl, r = nr, c = nc;
  }
} q[N];
int t[N * 4], m, n, tt[N * 4];
vector<pair<long long, int> > lol;
map<int, long long> mp;
void push(int v, int tl, int tr) {
  if (tt[v] == 0) return;
  int tm = (tr + tl) / 2;
  if (tt[v] == 1) {
    t[v * 2] = (tm - tl + 1);
    t[v * 2 + 1] = (tr - tm);
  } else if (tt[v] == 2) {
    t[v * 2] = 0;
    t[v * 2 + 1] = 0;
  } else {
    t[v * 2] = (tm - tl + 1) - t[v * 2];
    t[v * 2 + 1] = (tr - tm) - t[v * 2 + 1];
  }
  if (tt[v] != 3) {
    tt[v * 2] = tt[v];
    tt[v * 2 + 1] = tt[v];
  } else {
    if (tt[v * 2] == 0) {
      tt[v * 2] = tt[v];
    } else if (tt[v * 2] == 1) {
      tt[v * 2] = 2;
    } else if (tt[v * 2] == 2) {
      tt[v * 2] = 1;
    } else if (tt[v * 2] == 3) {
      tt[v * 2] = 0;
    }
    if (tt[v * 2 + 1] == 0) {
      tt[v * 2 + 1] = tt[v];
    } else if (tt[v * 2 + 1] == 1) {
      tt[v * 2 + 1] = 2;
    } else if (tt[v * 2 + 1] == 2) {
      tt[v * 2 + 1] = 1;
    } else if (tt[v * 2 + 1] == 3) {
      tt[v * 2 + 1] = 0;
    }
  }
  tt[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int c) {
  if (tl > r || l > tr) return;
  if (tl >= l && tr <= r) {
    if (c == 1) {
      t[v] = (tr - tl + 1);
      tt[v] = c;
    } else if (c == 2) {
      t[v] = 0;
      tt[v] = c;
    } else {
      t[v] = (tr - tl + 1) - t[v];
      if (tt[v] == 0) {
        tt[v] = c;
      } else if (tt[v] == 1) {
        tt[v] = 2;
      } else if (tt[v] == 2) {
        tt[v] = 1;
      } else {
        tt[v] = 0;
      }
    }
    return;
  }
  int tm = (tl + tr) / 2;
  push(v, tl, tr);
  upd(v * 2, tl, tm, l, r, c);
  upd(v * 2 + 1, tm + 1, tr, l, r, c);
  t[v] = t[v * 2] + t[v * 2 + 1];
}
int solve(int v, int tl, int tr) {
  if (tl == tr || t[v] == 0) {
    return tl;
  }
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  if (t[v * 2] != (tm - tl + 1)) {
    return solve(v * 2, tl, tm);
  } else {
    return solve(v * 2 + 1, tm + 1, tr);
  }
}
void NICEBATNIK(int v, int tl, int tr) {
  if (tl == tr) return;
  push(v, tl, tr);
  int tm = (tl + tr) / 2;
  NICEBATNIK(v * 2, tl, tm);
  NICEBATNIK(v * 2 + 1, tm + 1, tr);
}
int main() {
  scanf("%d", &m);
  lol.push_back(make_pair(1, 0));
  for (int i = 1; i <= m; i++) {
    int c;
    long long l, r;
    scanf("%d %lld %lld", &c, &l, &r);
    q[i] = Q(l, r, (long long)c);
    lol.push_back(make_pair(l, -i));
    lol.push_back(make_pair(r, i));
    if (l != 1) lol.push_back(make_pair(l - 1, 0));
    lol.push_back(make_pair(r + 1, 0));
  }
  sort(lol.begin(), lol.end());
  for (int i = 0; i < (int)lol.size(); i++) {
    if (i == 0 || lol[i].first != lol[i - 1].first) {
      n++;
    }
    if (lol[i].second < 0) {
      q[abs(lol[i].second)].l = n;
    } else {
      q[abs(lol[i].second)].r = n;
    }
    mp[n] = lol[i].first;
  }
  for (int i = 1; i <= m; i++) {
    upd(1, 1, n, q[i].l, q[i].r, q[i].c);
    long long ans = mp[solve(1, 1, n)];
    printf("%lld\n", ans);
  }
}