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++14 (judge verdict: Accepted)

#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class SegmentTree
{
 private:
    int n;
    vector<int> node;
 public:
    SegmentTree(int sz){
        n=1;
        while(n<sz) n*=2;
        node.resize(2*n);
        for(int i=1;i<n;i++) node[i]=-1;
        for(int i=n;i<2*n;i++) node[i]=INT_MAX;
    }
    void update(int a,int b,int val,int k=1,int l=0,int r=-1){
        if(r<0) r=n;
        if(r<=a or b<=l) return;
        if(a<=l and r<=b){
            node[k]=val;
            return;
        }
        if(node[k]!=-1){
            node[2*k]=node[2*k+1]=node[k];
            node[k]=-1;
        }
        update(a,b,val,2*k,l,(l+r)/2);
        update(a,b,val,2*k+1,(l+r)/2,r);
    }
    int get(int idx){
        idx+=n;
        int res=node[idx];
        while(idx>>=1){
            if(node[idx]!=-1) res=node[idx];
        }
        return res;
    }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,Q; cin>>N>>Q;
    SegmentTree seg(N);
    while(Q--){
        int q; cin>>q;
        if(q==0){
            int s,t,x; cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }else{
            int i; cin>>i;
            cout<<seg.get(i)<<endl;
        }
    }
    return 0;
}