#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int H, W, N, M; cin >> H >> W >> N >> M; vector T(N), U(N), L(N), R(N), A(N); REP(i, N) scanf("%d %d %d %d %d", &T[i], &U[i], &L[i], &R[i], &A[i]), --T[i], --L[i]; vector X(M), Y(M), B(M), C(M); REP(i, M) scanf("%d %d %d %d", &Y[i], &X[i], &B[i], &C[i]), --X[i], --Y[i]; vector imos(H + 1, vector(W + 1)); // 0-indexed 爆風ダメージ REP(i, M) { const int y1 = max(0, Y[i] - B[i]); const int y2 = min(H, Y[i] + B[i] + 1); // [y1, y2) const int x1 = max(0, X[i] - B[i]); const int x2 = min(W, X[i] + B[i] + 1); // [x1, x2) imos[y1][x1] += C[i]; imos[y2][x1] -= C[i]; imos[y1][x2] -= C[i]; imos[y2][x2] += C[i]; } REP(i, H) REP(j, W) imos[i][j + 1] += imos[i][j]; REP(i, H) REP(j, W) imos[i + 1][j] += imos[i][j]; vector sum(H + 1, vector(W + 1)); // 1-indexed 爆風ダメージ累積和 REP(i, H) REP(j, W) sum[i + 1][j + 1] = imos[i][j]; REP(i, H + 1) REP(j, W) sum[i][j + 1] += sum[i][j]; REP(i, H) REP(j, W + 1) sum[i + 1][j] += sum[i][j]; int ans = 0; REP(i, N) { // T, U, L, R const ll dmg = sum[U[i]][R[i]] - sum[U[i]][L[i]] - sum[T[i]][R[i]] + sum[T[i]][L[i]]; ans += dmg < A[i]; } cout << ans << endl; }