Problem:
Range Update Query (RUQ)

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

update(s, t, x): change as, as+1, ..., at to x.

find(i): output the value of ai.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 i

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).

Output

For each find operation, print the value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

0 ≤ s ≤ t < n

0 ≤ i < n

0 ≤ x < 231−1

Sample Input 1

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0
1 1

Sample Output 1

1
3

Sample Input 2

1 3
1 0
0 0 0 5
1 0

Sample Output 2

2147483647
5

Solution in C (judge verdict: Accepted)

// AOJ DSL_2_D Range Update Query (RUQ)
// 2018.5.18 bal4u

#include <stdio.h>

#define INF 0x7fffffff

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char *inf = "2147483647";

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else if (n == INF) for (i = 0; i < 10; i++) pc(inf[i]);
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N 100005
#define INF 0x7fffffff

int node[MAX_N << 2];


int find(int t, int l, int r, int x)
{
	int m;

	if (~node[t]) return node[t];
	m = (l + r) >> 1;
	if (x <= m) return find( t<<1, l, m, x);
	else        return find((t<<1)|1, m + 1, r, x);
}

void update(int t, int l, int r, int x, int y, int k)
{
	int m;

	if (l == x && r == y) { node[t] = k; return; }
	m = (l + r) >> 1;
	if (~node[t]) {
		node[t<<1] = node[(t<<1)|1] = node[t];
		node[t] = -1;
	}
	if (y <= m)	update(t<<1, l, m, x, y, k);
	else if (x > m)	update((t<<1)|1, m+1, r, x, y, k);
	else {
		update(t<<1, l, m, x, m, k);
		update((t<<1)|1, m+1, r, m+1, y, k);
	}
}

signed main(void)
{
	int n, q, sz;
	int op, s, t, x;

	n = in(), q = in();
	sz = n << 2;
	for (s = 0; s < sz; s++) node[s] = INF;

	while (q--) {
		op = gc() & 1, gc();
		if (op) out(find(1, 1, n, in()+1));
		else {
			s = in()+1, t = in()+1, x = in();
			update(1, 1, n, s, t, x);
		}
	}
	return 0;
}