#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

int n, q;
int res[100005], segm_pos[400005];

void update_pos(int v, int le, int ri, int pos, int st)
{
    if(ri<pos || le>pos) return;
    else if(le==ri) segm_pos[v]+=st;
    else
    {
        int mid=(le+ri)/2;
        update_pos(2*v, le, mid, pos, st);
        update_pos(2*v+1, mid+1, ri, pos, st);
        segm_pos[v]=segm_pos[2*v]+segm_pos[2*v+1];
    }
}

int query_pos(int v, int le, int ri, int be, int en)
{
    if(le>en || ri<be) return 0;
    else if(be<=le && ri<=en) return segm_pos[v];
    else
    {
        int mid=(le+ri)/2;
        return query_pos(2*v, le, mid, be, en)+query_pos(2*v+1, mid+1, ri, be, en);
    }
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>q;
    for(int i=0; i<q; i++)
    {
        int ty;
        cin>>ty;
        if(ty==1 || ty==2)
        {
            int p;
            cin>>p;
            update_pos(1, 1, n, p+1, 1);
        }
        if(ty==3)
        {
            int c, a;
            cin>>c>>a;
            res[c]+=a;
        }
        if(ty==4)
        {
            int l, r;
            cin>>l>>r;
            if(query_pos(1, 1, n, 1, r)%2) cout<<res[r]<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}

