/*
TASK:bands
LANG:C++
*/
#include<iostream.h>
unsigned comm,rul[20000][256],q,w,e,l;
unsigned long m,n;

void first(unsigned k, unsigned t,unsigned c,unsigned s)
{
     unsigned i;
     for (i=k;i<t;i++)
         rul[i][c]=s;
}
void second(unsigned z,unsigned x)
{
     int i,i1;
     unsigned long max;
     max=0;
     for (i=0;i<256;i++)
         if (max<rul[z][i]) { max=rul[z][i]; i1=i;}
       for (i=z;i<=x;i++)
         rul[i][i1]=0;
}
void third(unsigned b)
{
     unsigned long max1;
     int i,i2;
     i2=0;
          max1=0;
     for (i=0;i<256;i++)
         if (max1<rul[b][i]) { max1=rul[b][i]; i2=i;}
         cout<<i2<<endl;        

}
int main()
{
    unsigned long i;
   cin>>n>>m;
   for (i=1;i<=m;i++)
   {
         cin>>comm;
         switch (comm)      
          {
                case 1: l++; cin>>q>>w>>e; first(q,w,e,l); break;
                case 2: cin>>q>>e; second(q,e); break;
                case 3: cin>>q; third(q);break;
          }
   } 
   cin>>n;
}
