#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))


using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T>
void print(const T niz[], const int siz)
{
    for(int i=0;i<siz;i++)
        cout << niz[i] << " ";
    cout << endl;
}

int w,h,r,q;
pii krug[100005];
vector<int> duz[100005];
int res[100005];
map<pair<int,int>, bool>ima;
bool check(int x, int y){
    return (x<=w && y<=h && y>=0);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> w >> h >> r >> q;
    ff(i,0,w)res[i] = h;
    ff(i,0,q - 1){
        int t;
        cin >> t;
        if(t == 2){
            int x;
            cin >> x;
            cout << res[x] << endl;
            continue;
        }
        int x,y;
        cin >> x >> y;
        if(check(x,y - 1)){
            if(!ima[{x,y-1}]){
                res[x]--;
                ima[{x,y-1}] = 1;
            }
        }
        if(check(x,y + 1)){
            if(!ima[{x,y+1}]){
                res[x]--;
                ima[{x,y+1}] = 1;
            }
        }
    }

    return 0;
}