#include using namespace std; using int128 = __int128_t; #define rep(i, n) for (int i = 0; i < n; ++i) #define reps(i, n, s) for (int i = 0; i < n; i += s) #define repl(i, l, r) for (int i = l; i < r; ++i) #define repsl(i, l, r, s) for (int i = l; i < r; i += s) #define all(iterable) (iterable).begin(), (iterable).end() constexpr int dx4[4] = {1, 0, -1, 0}; constexpr int dy4[4] = {0, 1, 0, -1}; constexpr int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1}; constexpr int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; template void print(const vector& vec, const string sep = " ", const string end = "\n") { int n = vec.size(); rep(i, n) { cout << vec[i]; if (i < n - 1) cout << sep; else cout << end; } } template void read(vector& a, int begin_index, int length) { if (a.size() < begin_index + length) a.resize(begin_index + length); while (length --> 0) cin >> a[begin_index++]; } template void read(vector& a) { read(a, 0, a.size()); } int main() { int h, w, n, m; cin >> h >> w >> n >> m; vector> s(h + 1, vector(w + 1, 0)); vector> slimes(n); rep(i, n) { int u, d, l, r, a; cin >> u >> d >> l >> r >> a; slimes[i] = {u - 1, d, l - 1, r, a}; } rep(i, m) { int cr, cc, k, x; cin >> cr >> cc >> k >> x; --cr, --cc; int u = max(cr - k + 1, 1), d = min(cr + k + 1, h); int l = max(cc - k + 1, 1), r = min(cc + k + 1, w); s[u][l] += x; s[u][r] -= x; s[d][l] -= x; s[d][r] += x; } rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j]; rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j]; rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j]; rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j]; int ans = 0; for (auto &[u, d, l, r, a] : slimes) { long long t = s[d][r] - s[d][l] - s[u][r] + s[u][l]; ans += t < a; } cout << ans << '\n'; return 0; }