#include "bits/stdc++.h" //#include "atcoder/all" using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" long long imos[2002][2002]; long long sum[2002][2002]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w, n, m; cin >> h >> w >> n >> m; vectort(n), u(n), l(n), r(n), a(n); rep(i, n) { cin >> t[i] >> u[i] >> l[i] >> r[i] >> a[i]; t[i]--; u[i]--; l[i]--; r[i]--; } rep(i, m) { int x, y, b, c; cin >> x >> y >> b >> c; imos[max(1, x - b)][max(1, y - b)] += c; imos[min(h + 1, x + b + 1)][min(w + 1, y + b + 1)] += c; imos[max(1, x - b)][min(w + 1, y + b + 1)] -= c; imos[min(h + 1, x + b + 1)][max(1, y - b)] -= c; } rep(i, h + 1) { rep(j, w) { imos[i][j + 1] += imos[i][j]; } } rep(i, w + 1) { rep(j, h) { imos[j + 1][i] += imos[j][i]; } } rep2(i, 1, h + 1) { rep2(j, 1, w + 1) { sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + imos[i][j]; } } /*if (false) { rep(i, h + 2) { rep(j, w + 2) { cout << imos[i][j] << " "; } cout << endl; } cout << endl; rep(i, h + 1) { rep(j, w + 1) { cout << sum[i][j] << " "; } cout << endl; } }*/ int ans = 0; rep(i, n) { //[i,j) = s[j+1] - s[i]; long long att = sum[u[i] + 1][r[i] + 1] - sum[u[i] + 1][l[i]] - sum[t[i]][r[i] + 1] + sum[t[i]][l[i]]; a[i] -= att; if (a[i] > 0) ans++; } cout << ans << endl; return 0; }