#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int H, W, T, Q;

template <int Height, int Width>
struct bit_sum_2d {
    int arr[Height+1][Width+1];
    int height, width;

    bit_sum_2d() {
        height = Height;
        width = Width;
        for (int j = 0; j < height+1; ++j) {
            fill(arr[j], arr[j]+width+1, 0);
        }
    }

    void update(int h, int w, int a) {
        for (int j = h+1; j <= height; j += j&-j) {
            for (int k = w+1; k <= width; k += k&-k) {
                arr[j][k] += a;
            }
        }
    }

    int query(int h, int w) {
        int sum = 0;
        for (int j = h+1; j > 0; j -= j&-j) {
            for (int k = w+1; k > 0; k -= k&-k) {
                sum += arr[j][k];
            }
        }
        return sum;
    }

    int query(int h1, int w1, int h2, int w2) {
        return query(h2, w2) - query(h1-1, w2) - query(h2, w1-1) + query(h1-1, w1-1);
    }
};

struct taiyaki_t {
    int t; int h, w;
    taiyaki_t(int a, int b, int c): t(a), h(b), w(c) {}
};

bit_sum_2d<2000, 2000> b1, b2;
char status[2000][2000];

int main() {
    scanf("%d%d%d%d", &H, &W, &T, &Q);
    queue<taiyaki_t> tq;
    for (int j = 0; j < H; ++j) fill(status[j], status[j]+W, 0);
    for (int j = 0; j < Q; ++j) {
        int t, c, h, w, hh, ww;
        scanf("%d%d%d%d", &t, &c, &h, &w);
        --h; --w;

        while(!tq.empty() && tq.front().t <= t) {
            taiyaki_t f = tq.front(); tq.pop();
            b1.update(f.h, f.w, -1);
            b2.update(f.h, f.w, 1);
            status[f.h][f.w] = 1;
        }

        if (c == 0) {
            tq.emplace(t+T, h, w);
            b1.update(h, w, 1);
        } else if (c == 1) {
            if (status[h][w]) {
                status[h][w] = 0;
                b2.update(h, w, -1);
            }
        } else if (c == 2) {
            scanf("%d%d", &hh, &ww);
            --hh; --ww;

            cout << b2.query(h, w, hh, ww) << " " << b1.query(h, w, hh, ww) << endl;
        }
    }
    return 0;
}