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:
import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;

	HashMap<Long, Integer> map = new HashMap<Long, Integer>();

	class p {
		long z, f, pen;
		boolean val;

		p() {
			z = (long) 1e18 + 1;
			f = (long) 1e18 + 1;
			pen = -1;
			val = false;
		}
	}

	void merge(p x, p y, p z) {
		x.z = Math.min(y.z, z.z);
		x.f = Math.min(y.f, z.f);
	}

	p ar[];

	void build(int l, int r, int c) {
		if (l == r) {
			ar[c] = new p();
			ar[c].z = a[l];
			ar[c].f = (long) 1e18 + 1;
			return;
		}
		int mid = l + r >> 1;
		build(l, mid, 2 * c + 1);
		build(mid + 1, r, 2 * c + 2);
		ar[c] = new p();
		merge(ar[c], ar[2 * c + 1], ar[2 * c + 2]);
	}

	void update(int l, int r, int c, int x, int y, int val, boolean u) {
		if (ar[c].pen != -1) {
			if (ar[c].pen == 1) {
				ar[c].f = a[l];
				ar[c].z = (long) 1e18 + 1;
			} else {
				ar[c].z = a[l];
				ar[c].f = (long) 1e18 + 1;
			}
			if (ar[2 * c + 1] == null)
				ar[2 * c + 1] = new p();
			ar[2 * c + 1].pen = ar[c].pen;
			ar[2 * c + 1].val = false;
			if (ar[2 * c + 2] == null)
				ar[2 * c + 2] = new p();
			ar[2 * c + 2].pen = ar[c].pen;
			ar[2 * c + 2].val = false;
			ar[c].pen = -1;
		}
		if (ar[c].val) {
			long q = ar[c].z;
			ar[c].z = ar[c].f;
			ar[c].f = q;
			if (ar[2 * c + 1] == null)
				ar[2 * c + 1] = new p();
			ar[2 * c + 1].val = !ar[2 * c + 1].val;
			if (ar[2 * c + 2] == null)
				ar[2 * c + 2] = new p();
			ar[2 * c + 2].val = !ar[2 * c + 2].val;
			ar[c].val = false;
		}
		if (l > r || x > y || l > y || x > r)
			return;
		else if (x <= l && y >= r) {
			if (u) {
				long q = ar[c].z;
				ar[c].z = ar[c].f;
				ar[c].f = q;
				if (ar[2 * c + 1] == null)
					ar[2 * c + 1] = new p();
				ar[2 * c + 1].val = !ar[2 * c + 1].val;
				if (ar[2 * c + 2] == null)
					ar[2 * c + 2] = new p();
				ar[2 * c + 2].val = !ar[2 * c + 2].val;
			} else {
				if (val == 1) {
					ar[c].f = a[l];
					ar[c].z = (long) 1e18 + 1;
				} else {
					ar[c].z = a[l];
					ar[c].f = (long) 1e18 + 1;
				}
				if (ar[2 * c + 1] == null)
					ar[2 * c + 1] = new p();
				ar[2 * c + 1].pen = val;
				ar[2 * c + 1].val = false;
				if (ar[2 * c + 2] == null)
					ar[2 * c + 2] = new p();
				ar[2 * c + 2].pen = val;
				ar[2 * c + 2].val = false;
			}
			return;
		}
		int mid = l + r >> 1;
		update(l, mid, 2 * c + 1, x, y, val, u);
		update(mid + 1, r, 2 * c + 2, x, y, val, u);
		merge(ar[c], ar[2 * c + 1], ar[2 * c + 2]);
	}

	long a[];

	void solve() {
		int n = ni();
		long arr[][] = new long[n][3];
		TreeSet<Long> set = new TreeSet<Long>();
		for (int i = 0; i < n; i++) {
			arr[i][0] = nl();
			arr[i][1] = nl();
			arr[i][2] = nl();
			set.add(arr[i][1]);
			set.add(arr[i][2]);
		}
		set.add((long) 1);
		set.add((long) 1e18 + 1);
		int k = set.size();
		a = new long[10 * n];
		for (int i = 0; !set.isEmpty(); i++)
			a[i] = set.pollFirst();
		int cu = k;
		for (int i = 1; i < k; i++) {
			if (a[i] - a[i - 1] > 1)
				a[cu++] = a[i - 1] + 1;
		}
		Arrays.sort(a, 0, cu);
		k = 0;
		for (int i = 0; i < cu; i++)
			map.put(a[i], k++);
		ar = new p[10 * cu];
		build(0, cu - 1, 0);
		for (int i = 0; i < n; i++) {
			if (arr[i][0] == 1)
				update(0, cu - 1, 0, map.get(arr[i][1]), map.get(arr[i][2]), 1, false);
			else if (arr[i][0] == 2)
				update(0, cu - 1, 0, map.get(arr[i][1]), map.get(arr[i][2]), 2, false);
			else
				update(0, cu - 1, 0, map.get(arr[i][1]), map.get(arr[i][2]), 1, true);
			out.println(ar[0].z);
		}
	}

	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new CODEFORCES().soln();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}