/*
TASK:bands
LANG:C++
*/
#include <stdio.h>
#include <vector>
#define pb push_back
#define maxlen 65536
#define maxm 100010
#define undef 0
#define FOR(i,n) for(int i=0;i<n;i++)

struct itree {
       bool def;
       std::vector<int> col;
       itree() { def = true; }
} it[maxlen];

void add(int node,int l,int r,int a,int b,int col) {
     if(r < a || l > b) return;
     if(a<=l && r<=b) {
             it[node].col.pb(col);
             it[node].def = !undef;
     }
     else {
          it[node].def = undef; // undefined
          int mid = (l+r)/2;
          if(mid>=l) add(node*2,l,mid,a,b,col);
          if(mid<r) add(node*2+1,mid+1,r,a,b,col);
     }
}

int n,m;

int query(int node,int l,int r,int ind) {
    if(l<=ind && ind<=r && it[node].def != undef) {
              if(it[node].col.empty()) return 0;
              return it[node].col[ (int)it[node].col.size() - 1 ];
    }
    int mid = (l+r)/2;
    if(mid >= ind) return query(node*2,l,mid,ind);
    else return query(node*2+1,mid+1,r,ind);
}
void pop(int node,int l,int r,int a,int b) {
     if(r<a || b<l) return;
     if(a<=l && r<=b && it[node].def != undef) {
               if(it[node].col.empty()) return;
               it[node].col.pop_back();
               return;
     }
     it[node].def = undef;
     int mid = (l+r)/2;
     if(mid>=l) pop(node*2,l,mid,a,b);
     if(mid<r) pop(node*2+1,mid+1,r,a,b);
}

int main() {
    scanf("%d %d",&n,&m);
    
    FOR(i,m) {
             int com;
             scanf("%d",&com);
             int from,to,col;
             if(com == 1) {
                    scanf("%d %d %d",&from,&to,&col);
                    add(1,0,maxlen>>1,from,to-1,col);
             }
             else if(com == 2) {
                  scanf("%d %d",&from,&to);
                  pop(1,0,maxlen>>1,from,to);
             }
             else if(com==3) {
                  int ind;
                  scanf("%d",&ind);
                  printf("%d\n",query(1,0,maxlen>>1,ind));
             }
    }
//  scanf("%d\n",&n);
    return 0;
}
