#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

long long gcd(long long a, long long b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        long long r = a%b;
        a=b;
        b=r;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //x???n???????¨????????????????n??????2?????¨?¨???????????¨????
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//???????????????
        }
        x=(x*x)%mod;//2???
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    long long min=0;
    long long kake=0;
};

class xxIntu {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //?¬¬1?????¶
        if(riLeft.kake != riRight.kake){
            return riLeft.kake > riRight.kake;//<:??????(?°??????????)???>:??????(??§?????????)
        }
        //?¬¬2?????¶
        return riLeft.min > riRight.min;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/

int funC(int a,int b){
    int tmp=1;
    int tmp2=1;
    for(int i=0;i<b;i++){
        tmp=tmp*(a-i);
        tmp2=tmp2*(b-i);
    }
    return tmp/tmp2;
}

int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //???????????¨
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //????????????

    int W,H,T,p;
    cin >> W >> H >> T >>p;
    int x[125000];
    int y[125000];
    int t[125000];
    int s[50][50];
    
    for(int i=0;i<p;i++){
        cin >> x[i] >> y[i] >> t[i];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[j][i];
        }
    }
    
    for(int i=0;i<p;i++){
        if(t[i]<=T && s[x[i]][y[i]]!=0){
            s[x[i]][y[i]]++;
        }
    }
    
    int ans=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[j][i]!=0){
                ans=ans+s[j][i]-1;
            }
        }
    }
    
    cout << ans << endl;

    
    //???????????§
    //cout << "ans" << endl;????????????
    //printf("%.0f\n",ans);//?°???°?????\?????¨?????????
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 3116