#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void) {
	int i, j, k, l;
	int W, H, T;
	int p;
	int x[55] , y[55] , t[55];
	int field[55][55];
	cin >> W >> H >> T;
	cin >> p;
	rep(i, p) {
		cin >> x[i] >> y[i] >> t[i];
	}
	rep(i, H) rep(j, W) {
		cin >> field[i][j];
	}
	int cnt = 0;
	rep(i, p) {
		if (field[y[i]][x[i]]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}