#include #include using namespace std; using namespace atcoder; #define rep(i,n)for (int i = 0; i < int(n); ++i) #define rrep(i,n)for (int i = int(n)-1; i >= 0; --i) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() template void chmax(T& a, const T& b) {a = max(a, b);} template void chmin(T& a, const T& b) {a = min(a, b);} using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w, n, m; cin >> h >> w >> n >> m; VVL s(h + 1, VL(w + 1)); struct Slime { int u, d, l, r, a; }; vector slimes(n); for(auto& slm: slimes) cin >> slm.u >> slm.d >> slm.l >> slm.r >> slm.a, slm.u--, slm.l--; rep(_, m) { int x, y, b, c; cin >> x >> y >> b >> c; int u = max(0, x - b), d = min(x + b + 1, h), l = max(0, y - b), r = min(w, y + b + 1); s[u][l] += c; s[u][r] -= c; s[d][l] -= c; s[d][r] += c; } rep(i, h + 1) { ll now = 0; rep(j, w + 1) { now += s[i][j]; s[i][j] = now; } } rep(j, w + 1) { ll now = 0; rep(i, h + 1) { now += s[i][j]; s[i][j] = now; } } VVL sm(h + 1, VL(w + 1)); rep(i, h) rep(j, w) sm[i+1][j+1] = s[i][j] + sm[i+1][j] + sm[i][j+1] - sm[i][j]; int ans = 0; for(auto slm: slimes) { int u = slm.u, d = slm.d, l = slm.l, r = slm.r; ll rm = slm.a - (sm[d][r] - sm[u][r] - sm[d][l] + sm[u][l]); ans += rm > 0; } cout << ans << '\n'; }