/*
TASK:bands
LANG:C++
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define MN 20002
long n,m;
char a[MN];
struct bands
{
    long x,y,c;
};
vector <bands> t;
bool cmp(bands p,bands o)
{
    if(p.y<o.y)return p.y<o.y;
    else if(p.y=o.y) return p.x<o.x;
    return 0;
}
void addb(long x,long y,long c)
{
    int i;
    for(i=x;i<y;i++)
        a[i]=c;
    bands s;
    s.x=x;
    s.y=y;
    s.c=c;
    t.push_back(s);
}
void removeb(long x,long y)
{
    int i,j,lamp=0;
    sort(t.begin(),t.end(),cmp);
    for(i=0;i<t.size();i++)
    {
        if(lamp==0)
            if(t[i].y<=y&&t[i].x>=x)
            {lamp=i+1;}
        else
        {
            if(t[i].y<=t[lamp-1].x&&t[i].x<=t[lamp-1].x)
                break;
            else
                lamp=0;
        }
    }
    if(lamp)
    {
        for(i=t[lamp-1].x;i<t[lamp-1].y;i++)
            a[i]=0;
        t[lamp-1]=t[t.size()-1];
        t.pop_back();  
    }     
}
void ask(long x)
{
    printf("%ld\n",a[x]);
}
void solve()
{
    long i,j;
    long q,x,y,c;
    string s;
    scanf("%ld%ld",&n,&m);
    for(j=1;j<=m;j++)
    {
        scanf("%ld%ld",&q,&x);
        if(q==2)
            {scanf("%ld",&y);removeb(x,y);}
        if(q==1)
            {scanf("%ld%ld",&y,&c); addb(x,y,c);}
        if(q==3)
            ask(x);
    }
}
int main()
{
    solve();
    system("pause");
    return 0;
    
}
