#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


template<class T>
struct BIT2D{
    vector<vector<T> > bit2d;

    // bit is 1-indexed
    BIT2D(ll n, ll m) : bit2d(n + 1, vector<T>(m + 1, 0)) { }

    void add(ll a, ll b, T x){
        for (ll i = a; i < (ll)bit2d.size(); i += i & -i){
            for (ll j = b; j < (ll)bit2d[0].size(); j += j & -j){
                bit2d[i][j] = bit2d[i][j] + x;
            }
        }
    }

    T sum(ll a, ll b){
        T res = 0;
        for (ll i = a; i > 0; i -= i & -i){
            for (ll j = b; j > 0; j -= j & -j){
                res += bit2d[i][j];
            }
        }
        return res;
    }

    // a1 <= x < b1, a2 <= y < b2 の総和　
    T sum(ll a1, ll a2, ll b1, ll b2){
        return sum(b1-1, b2-1) - sum(a1-1, b2-1) - sum(b1-1, a2-1) + sum(a1-1, a2-1);
    }


    // debug
    void print() {
        for (ll i = 1; i < (ll)bit2d.size(); i++){
            for (ll j = 1; j < (ll)bit2d.size(); j++){
                cout << sum(i, j, i+1, j+1) << ", ";
                // cout << bit2d[i][j] << ", ";
            }
            cout << endl;
        }
    }


};




void solve(){
    ll H,W,T,Q;
    cin>>H>>W>>T>>Q;
    BIT2D<ll> fin(H,W), yet(H,W);
    queue<ppll> que;
    rep(query,Q){
        ll t,c,h1,w1;
        cin>>t>>c>>h1>>w1;
        while(!que.empty()){
            ppll a = que.front();
            if(a.first > t) break;
            yet.add(a.sc.fi,a.sc.sc,-1);
            fin.add(a.sc.fi,a.sc.sc,1);
            que.pop();

        }
        if(c==0) {
            yet.add(h1,w1,1);
            que.push(make_pair(t+T,pll(h1,w1)));
        }
        else if(c==1){
            if(fin.sum(h1,w1,h1+1,w1+1) == 1){
                fin.add(h1,w1,-1);
            }
        }
        else{
            ll h2,w2;
            cin>>h2>>w2;
            cout<<fin.sum(h1,w1,h2+1,w2+1)<<" "<<yet.sum(h1,w1,h2+1,w2+1)<<endl;
        }
    }

}




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    solve(); 


    return 0;
}

