/*
TASK: BANDS
LANG: C
*/
#include <stdio.h>

 struct strip
  {
   int co,l,r,time;
   struct strip *next;
  };

 struct node
  {
   int l,r;
   struct strip *p;
  };

 int n,m;
 struct node bin[1024*256];
 int size;
 struct strip mem[(1<<22)];
 int x,y,z,com;

 void init_tree (int node,int l,int r)
  {
   bin[node].l=l;
   bin[node].r=r;
   if (l==r) return;
   init_tree(node*2,l,(l+r)/2);
   init_tree(node*2+1,(l+r)/2+1,r);
  }

 void put_strip (int co,int node)
  {
   (mem+(++size))->next=bin[node].p;
   bin[node].p=mem+size;
   bin[node].p->time=m;
   bin[node].p->co=co;
  }

 void rm_strip (int co,int node)
  {
   bin[node].p=bin[node].p->next;
  }

 void go (int l,int r,int co,int node,int action)
  {
   if (bin[node].l==l && bin[node].r==r)
    {
     if (action==1)  put_strip(co,node);
     if (action==2)  rm_strip(co,node);
     return;
    }
   int med=(bin[node].l+bin[node].r)/2;
   if (med>=r)  go(l,r,co,node*2,action);
   if (med<l)   go(l,r,co,node*2+1,action);
   if (l<=med && r>med)
    {
     go(l,med,co,node*2,action);
     go(med+1,r,co,node*2+1,action);
    }
  }

 void get (int z,int node)
  {
   if (bin[node].p!=NULL && bin[node].p->time<y)
    {
     y=bin[node].p->time;
     x=bin[node].p->co;
    }    
   if (bin[node].l==z && bin[node].r==z)
    return;
   int med=(bin[node].l+bin[node].r)/2;
   if (z<=med)  get(z,node*2);
   if (z>med)   get(z,node*2+1);
  }  

 int main ()
  {
   scanf("%d%d",&n,&m);
   init_tree(1,1,n);
   for (;m>0;m--)
    {
     scanf("%d",&com);
     if (com==1)
      {
       scanf("%d%d%d",&x,&y,&z);
       go(x+1,y,z,1,1);
      }
     if (com==2)
      {
       scanf("%d%d",&x,&y);
       go(x+1,y,-1,1,2);
      }
     if (com==3)
      {
       scanf("%d",&z);
       x=0;
       y=(int)1e9;
       get(z+1,1);
       printf("%d\n",x);
      }
    }
   return 0;
  }
