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>
#pragma comment(linker, "/stack:640000000")
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
template <class T>
inline T _abs(T n) {
  return ((n) < 0 ? -(n) : (n));
}
template <class T>
inline T _max(T a, T b) {
  return (!((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _min(T a, T b) {
  return (((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _swap(T& a, T& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
template <class T>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
struct quer {
  int t;
  long long l, r;
  quer(int a, long long b, long long c) {
    t = a;
    l = b;
    r = c;
  }
};
vector<quer> vq;
map<long long, int> mp;
map<int, long long> rev;
vector<long long> v;
struct info {
  int sum;
  int prop;
} tree[300004 * 4];
info call(info a, info b) {
  info tmp;
  tmp.sum = a.sum + b.sum;
  tmp.prop = 0;
  return tmp;
}
void init(int node, int b, int e) {
  if (b == e) {
    tree[node].sum = 0;
    tree[node].prop = 0;
    return;
  }
  int Left = node << 1;
  int Right = (node << 1) + 1;
  int mid = (b + e) >> 1;
  init(Left, b, mid);
  init(Right, mid + 1, e);
  tree[node] = call(tree[Left], tree[Right]);
}
void propagate(int node, int b, int e) {
  if (b == e) {
    tree[node].prop = 0;
    return;
  }
  int Left = node << 1;
  int Right = (node << 1) + 1;
  int mid = (b + e) >> 1;
  int propa = tree[node].prop;
  if (propa == 1) {
    tree[Left].prop = 1;
    tree[Right].prop = 1;
  } else if (propa == 2) {
    tree[Left].prop = 2;
    tree[Right].prop = 2;
  } else if (propa == 3) {
    if (tree[Left].prop == 1)
      tree[Left].prop = 2;
    else if (tree[Left].prop == 2)
      tree[Left].prop = 1;
    else if (tree[Left].prop == 3)
      tree[Left].prop = 0;
    else
      tree[Left].prop = 3;
    if (tree[Right].prop == 1)
      tree[Right].prop = 2;
    else if (tree[Right].prop == 2)
      tree[Right].prop = 1;
    else if (tree[Right].prop == 3)
      tree[Right].prop = 0;
    else
      tree[Right].prop = 3;
  }
  tree[node].prop = 0;
  if (propa == 1)
    tree[Left].sum = mid - b + 1;
  else if (propa == 2)
    tree[Left].sum = 0;
  else
    tree[Left].sum = (mid - b + 1) - tree[Left].sum;
  if (propa == 1)
    tree[Right].sum = e - mid;
  else if (propa == 2)
    tree[Right].sum = 0;
  else
    tree[Right].sum = (e - mid) - tree[Right].sum;
}
long long query(int node, int b, int e) {
  if (tree[node].prop) propagate(node, b, e);
  if (b == e) {
    return rev[b];
  }
  int Left = node << 1;
  int Right = (node << 1) + 1;
  int mid = (b + e) >> 1;
  if (tree[Left].sum == (mid - b + 1)) {
    return query(Right, mid + 1, e);
  } else {
    return query(Left, b, mid);
  }
}
void update(int node, int b, int e, int i, int j, int newVal) {
  if (tree[node].prop) propagate(node, b, e);
  if (i > e || j < b) return;
  if (b >= i && e <= j) {
    if (newVal == 1) {
      tree[node].prop = 1;
      tree[node].sum = (e - b + 1);
    } else if (newVal == 2) {
      tree[node].prop = 2;
      tree[node].sum = 0;
    } else {
      tree[node].prop = 3;
      tree[node].sum = (e - b + 1) - tree[node].sum;
    }
    return;
  }
  int Left = node << 1;
  int Right = (node << 1) + 1;
  int mid = (b + e) >> 1;
  update(Left, b, mid, i, j, newVal);
  update(Right, mid + 1, e, i, j, newVal);
  tree[node] = call(tree[Left], tree[Right]);
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    vq.clear();
    mp.clear();
    rev.clear();
    v.clear();
    for (int i = (int)(1); i <= (int)(n); i++) {
      int t;
      long long x, y;
      scanf("%d", &t);
      scanf("%lld%lld", &x, &y);
      vq.push_back(quer(t, x, y));
      v.push_back(x);
      v.push_back(y);
      v.push_back(y + 1);
    }
    sort(v.begin(), v.end());
    (v).erase(unique((v).begin(), (v).end()), (v).end());
    mp[1] = 1;
    rev[1] = 1;
    int in = 2;
    for (int i = (int)(0); i <= (int)(v.size() - 1); i++) {
      ;
      if (mp[v[i]] == 0) {
        mp[v[i]] = in;
        rev[in] = v[i];
        in++;
      }
      if (mp[v[i]] == 0) {
        mp[v[i]] = in;
        rev[in] = v[i];
        in++;
      }
    }
    for (int i = (int)(0); i <= (int)(n - 1); i++) {
      vq[i].l = mp[vq[i].l];
      vq[i].r = mp[vq[i].r];
    }
    init(1, 1, in);
    for (int i = (int)(0); i <= (int)(n - 1); i++) {
      int t = vq[i].t;
      update(1, 1, in, vq[i].l, vq[i].r, t);
      printf("%lld\n", query(1, 1, in));
    }
  }
  return 0;
}