/*
TASK: bands
lANG: C++
*/

#include <cstdio>
#include <vector>

using namespace std;

struct cmd {
    int type;
    int l, r, col;
    cmd(int d=0, int t1=0, int t2=0, int t3=0) : type(d), l(t1), r(t2), col(t3) {}
};

vector<cmd> v;
int n, q;

int main() {

    scanf("%d %d", &n, &q);

    for(int i = 0; i < q; ++i) {
        int command;
        scanf("%d", &command);
        if( command == 1 ) {
            int a, b, c; scanf("%d %d %d", &a, &b, &c);            
            v.push_back( cmd(1, a, b, c) );
        }
        else if( command == 2 ) {
            int a, b;
            scanf("%d %d", &a, &b);
            v.push_back( cmd(2, a, b) );
        }
        else {
            int a, col = 0;
            scanf("%d", &a);
            int cnt = 1;
            for(int i = v.size()-1; i >= 0 && cnt; --i) {
                if( v[i].type == 2 && v[i].l <= a && v[i].r >= a ) ++cnt;
                if( v[i].type == 1 && v[i].l <= a && v[i].r >= a ) {
                    --cnt;
                    if( cnt == 0 ) col = v[i].col;
                }
            }
            printf("%d\n", col);
        }
    }

    return 0;
}
