#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

template <class T> struct FenwickTree2D {

    vector < vector < T > > node;
    FenwickTree2D (int h, int w) : node(h, vector < T > (w, 0)) {}

    void add(int x, int y, T val) {
        for (int i = x; i < node.size(); i |= i + 1) {
            for (int j = y; j < node[i].size(); j |= j + 1) {
                node[i][j] += val;
            }
        }
    }

    void update(int x, int y, T val) {
        add(x, y, -sum(x, y, x + 1, y + 1));
        add(x, y, val);
    }

    T sum(int x, int y) {
        T ret = 0;
        for (int i = x - 1; i >= 0; i = (i & (i + 1)) - 1) {
            for (int j = y - 1; j >= 0; j = (j & (j + 1)) - 1) {
                ret += node[i][j];
            }
        }
        return ret;
    }

    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x2, y1) - sum(x1, y2) + sum(x1, y1);
    }

};

int main() {

    int H,W,T,Q;
    cin >> H >> W >> T >> Q;

    queue < vector < int > > que;
    FenwickTree2D < int > inst1(2010, 2010);
    FenwickTree2D < int > inst2(2010, 2010);

    REP(kai, Q) {
        int t,c,h,w;
        scanf("%d%d%d%d", &t, &c, &h, &w);
        while (!que.empty()) {
            vector < int > v = que.front();
            if (v[0] <= t) {
                inst1.update(v[1], v[2], 0);
                inst2.update(v[1], v[2], 1);
                que.pop();
            } else {
                break;
            }
        }
        if (c == 0) {
            que.push({t + T, h, w});
            inst1.update(h, w, 1);
        } else if (c == 1) {
            inst2.update(h, w, 0);
        } else {
            int h2, w2;
            scanf("%d%d", &h2, &w2);
            h2++, w2++;
            cout << inst2.sum(h, w, h2, w2) << " " << inst1.sum(h, w, h2, w2) << endl;
        }
    }

    return 0;
}