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 JAVA):

Solution:
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF817F {
	static int[] tt;
	static int[][] lr;
	static long[][] lr_;
	static long[] xx;
	static int[] cnt;
	static char[] lazy;
	static final void setlr(int i, int x) { lr[i / 2][i % 2] = x; }
	static final long getlr(int i) { return lr_[i / 2][i % 2]; }
	static int compress(int n) {
		Integer[] ii = new Integer[n * 2];
		for (int h = 0; h < n * 2; h++)
			ii[h] = h;
		Arrays.sort(ii, (i, j) -> { long lri = getlr(i), lrj = getlr(j);
			return lri == lrj ? 0 : lri < lrj ? -1 : 1;
		});
		xx = new long[n * 2];
		int m = 0;
		for (int h = 0; h < n * 2; h++) {
			int i = ii[h];
			long x = getlr(i);
			xx[m] = x;
			setlr(i, h + 1 == n * 2 || x != getlr(ii[h + 1]) ? m++ : m);
		}
		return m;
	}
	static void update(int k, int l, int r, int ql, int qr, int type) {
		if (qr <= l || r <= ql)
			return;
		if (ql <= l & r <= qr) {
			if (type == 1) {
				cnt[k] = r - l;
				lazy[k] = 1;
			} else if (type == 2) {
				cnt[k] = 0;
				lazy[k] = 2;
			} else if (type == 3) {
				cnt[k] = r - l - cnt[k];
				lazy[k] = (char) (3 - lazy[k]);
			}
			return;
		}
		int m = (l + r) / 2;
		int k1 = k + k + 1, k2 = k + k + 2;
		if (lazy[k] != 0) {
			update(k1, l, m, l, m, lazy[k]);
			update(k2, m, r, m, r, lazy[k]);
			lazy[k] = 0;
		}
		update(k1, l, m, ql, qr, type);
		update(k2, m, r, ql, qr, type);
		cnt[k] = cnt[k1] + cnt[k2];
	}
	static int query(int k, int l, int r) {
		if (cnt[k] == r - l)
			return -1;
		if (cnt[k] == 0)
			return l;
		int m = (l + r) / 2;
		int k1 = k + k + 1, k2 = k + k + 2;
		if (lazy[k] != 0) {
			update(k1, l, m, l, m, lazy[k]);
			update(k2, m, r, m, r, lazy[k]);
			lazy[k] = 0;
		}
		int i = query(k1, l, m);
		return i != -1 ? i : query(k2, m, r);
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		tt = new int[n];
		lr_ = new long[n][2];
		boolean has1 = false;
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			tt[i] = Integer.parseInt(st.nextToken());
			if ((lr_[i][0] = Long.parseLong(st.nextToken())) == 1)
				has1 = true;
			lr_[i][1] = Long.parseLong(st.nextToken()) + 1;
		}
		lr = new int[n][2];
		int m = compress(n);	// m <= n * 2
		int p = 1;
		while (p < m)
			p *= 2;
		cnt = new int[p * 2];
		lazy = new char[p * 2];
		for (int i = 0; i < n; i++) {
			long ans = 1;
			if (has1) {
				update(0, 0, p, lr[i][0], lr[i][1], tt[i]);
				ans = xx[query(0, 0, p)];
			}
			pw.println(ans);
		}
		pw.close();
	}
}