/*
TASK:bands
LANG:C++
*/
#include <iostream>
using namespace std;

class Node
{
      public:
             int a,b,c;
             Node *left,*right,*mid;
             Node(){a=b=c=0;left=right=mid=0;}
};
class Tree
{
      private:
              Node root;
      public:
             Tree()
             {
                   root.a=-2;
                   root.b=-1;
                   root.c=0;
             }
             void insert(int x,int y,int z)
             {
                  Node *now=&root;
                  while(1)
                  {
                          if(y<=now->a)
                          {
                                       if(now->left==0)
                                       {
                                                       now->left=new Node;
                                                       now->left->a=x;
                                                       now->left->b=y;
                                                       now->left->c=z;
                                                       break;
                                       }
                                       now=now->left;
                          }
                          else if(x>=now->b)
                          {
                               
                                       if(now->right==0)
                                       {
                                                       now->right=new Node;
                                                       now->right->a=x;
                                                       now->right->b=y;
                                                       now->right->c=z;
                                                       break;
                                       }
                                       now=now->right;
                          }
                          else if((x>=now->a && x<now->b) || (y<=now->b && y>now->a))
                          {
                               
                                       if(now->mid==0)
                                       {
                                                       now->mid=new Node;
                                                       now->mid->a=x;
                                                       now->mid->b=y;
                                                       now->mid->c=z;
                                                       break;
                                       }
                                       now=now->mid;
                          }
                  }
             }
             
             int search(int i)
             {
                 int color=0;
                 Node *now=&root;
                 while(now!=0)
                 {
                        if(i<now->a)
                                    now=now->left;
                        else if(i>=now->b)
                                     now=now->right;
                        else if(i>=now->a && i<now->b)
                        {
                                     if(now->c!=-1)color=now->c;
                                     now=now->mid;
                        }
                 }
                 
                 return color;
             }
             void remove(int x,int y)
             {
                  Node* now=&root;
                  while(now!=0)
                  {
                               if(now->a==x && now->b==y) {now->c=-1;return;}
                               if(y<=now->a) now=now->left;
                               if(x>=now->b) now=now->right;
                               else now=now->mid;
                  }
             }
                               
};
Tree t;
int main()
{
 
 int cmd,c1,c2,c3,n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
            cin>>cmd;
            switch(cmd)
            {
                       case 1:
                              cin>>c1>>c2>>c3;
                              t.insert(c1,c2,c3);
                              break;
                       case 2:
                              cin>>c1>>c2;
                              t.remove(c1,c2);
                              break;
                       case 3:
                              cin>>c1;
                              cout<<t.search(c1)<<endl;
                              break;
            }
    }
 
}
