#include<bits/stdc++.h>
using namespace std;
const int maxn = 200002;
int n,q;
int a[maxn];
int tree[maxn*4];
int lazy[maxn*4];
void push_lazy( int i, int l, int r)
{
    if( l == r ) return;
    lazy[i*2] += lazy[i];
    lazy[i*2+1] += lazy[i];
    lazy[i] = 0;
    return;
}
void update_lazy( int i, int l, int r, int ql, int qr )
{
    push_lazy(i,l,r);
    if( l == ql && r == qr )
    {
        //cout << l << " ---- " << i << endl;
        lazy[i] += 1;
        push_lazy(i,l,r);
        //cout << lazy[i] << endl;
        return;
    }
    int m = ( l + r ) / 2;
    if( qr <= m ) update_lazy(i*2,l,m,ql,qr);
    else if( ql > m ) update_lazy(i*2+1,m+1,r,ql,qr);
    else
    {
        update_lazy(i*2,l,m,ql,m);
        update_lazy(i*2+1,m+1,r,m+1,qr);
    }
    return;
}
int query( int i, int l, int r, int pos )
{
    push_lazy(i,l,r);
    if( l == r )
    {
        //cout << l << " ******* " << i << endl;
        if( lazy[i] % 2 == 1 ) tree[i] = ( tree[i] ^ 1 );
        lazy[i] = 0;
        return tree[i];
    }
    int m = ( l + r ) / 2;
    if( pos <= m ) return query(i*2,l,m,pos);
    else return query(i*2+1,m+1,r,pos);
}
void read()
{
    cin >> n >> q;
    for( int i = 1; i <= q; i ++ )
    {
        int type;
        cin >> type;
        if( type == 1 || type == 2 )
        {
            int pos;
            cin >> pos;
            update_lazy(1,1,n,pos+1,n);
        }
        else if( type == 3 )
        {
            int pos,x;
            cin >> pos >> x;
            a[pos] += x;
        }
        else
        {
            int l,r;
            cin >> l >> r;
            int x = query(1,1,n,l);
            if( x == 1 ) cout << a[l] << endl;
            else cout << 0 << endl;
        }
    }
}
int main()
{
    read();
    return 0;
}
