
/*
TASK:bands
LANG:C
*/

//#define DEBUG

#include<stdio.h>
#define MAX 131072

void push(int ,int ,int ,int ,int ,int );
void cut(int ,int ,int ,int ,int );
void get(int );

typedef struct {
               int col,last,oc;
               } ind;

ind ind_tree[MAX<<1];
int color[16*MAX][4];
int o=1;

int main () {
    int n,m;
    int i;
    int s,e,c;
    int type;

    #ifdef DEBUG
    freopen("test.txt","rt",stdin);
    #endif
    
    for (i=0;i<(MAX<<1);i++)
        ind_tree[i].last=-1;
    scanf("%d %d",&n,&m);
    for (i=0;i<m;i++) {
        scanf("%d",&type);
        if (type==1) {
           scanf("%d %d %d",&s,&e,&c);
           e--;
           push(0,0,MAX-1,s,e,c);
           }
        if (type==2) {
           scanf("%d %d",&s,&e);
           //cut(0,0,MAX,s,e);
           }
        if (type==3) {
           scanf("%d",&s);
           get(s);
           }
        }
    return 0;
    }

void push(int pos,int ps,int pe,int rs,int re,int col) {
     if (ps>pe) return ;
     if (ind_tree[pos].oc==1) {
        ind_tree[pos].oc=0;
        if (rs-1>=ps)
           push(pos,ps,pe,ps,rs-1,ind_tree[pos].col);
        if (re+1<=pe)
           push(pos,ps,pe,re+1,pe,ind_tree[pos].col);
        push(pos,ps,pe,rs,re,col);
        return ;
        }        
     int mid=(ps+pe)>>1;
     if (rs<=ps&&pe<=re) {
        int t;
        t=ind_tree[pos].last;
        if (t!=-1)
           color[t][2]=o;
        color[o][0]=t;
        color[o][1]=col;
        ind_tree[pos].col=col;
        ind_tree[pos].oc=1;
        ind_tree[pos].last=o;
        o++;
        return ;
        }
     if (rs<=mid) push(2*pos+1,ps,mid,rs,re,col);
     if (re>mid) push(2*pos+2,mid+1,pe,rs,re,col);
     return ;
     }
     
void cut(int pos,int ps,int pe,int rs,int re) {
     int mid=ps+pe>>1;
     if (ind_tree[pos].oc==1) {
        push(pos,ps,pe,ps,rs-1,ind_tree[pos].col);
        push(pos,ps,pe,re+1,pe,ind_tree[pos].col);
        push(pos,ps,pe,rs,re,re);
        }
     return ;
     }

void get(int sp) {
     int pos=0;
     int ps=0,pe=MAX-1;
     int mid;
     while (1) {
           if (ind_tree[pos].oc==1||ps==pe) {
              printf("%d\n",ind_tree[pos].col);
              return ;
              }
           mid=(ps+pe)>>1;
           if (mid<sp) {
              pos=2*pos+2;
              ps=mid+1;
              }
           else {
                pos=2*pos+1;
                pe=mid;
                }
           }
     }

