#include #include #include using namespace std; using lint = long long; void solve() { int h, w, n, m; cin >> h >> w >> n >> m; vector> slimes(n); for (auto& [lx, rx, ly, ry, t] : slimes) { cin >> lx >> rx >> ly >> ry >> t; } auto grid = vector(h + 2, vector(w + 2, 0LL)); while (m--) { int cx, cy, b; cin >> cx >> cy >> b; auto lx = max(1, cx - b), rx = min(h, cx + b), ly = max(1, cy - b), ry = min(w, cy + b); lint c; cin >> c; grid[lx][ly] += c, grid[lx][ry + 1] -= c; grid[rx + 1][ly] -= c, grid[rx + 1][ry + 1] += c; } for (int x = 0; x < h + 2; ++x) { for (int y = 1; y < w + 2; ++y) { grid[x][y] += grid[x][y - 1]; } } for (int x = 1; x < h + 2; ++x) { for (int y = 0; y < w + 2; ++y) { grid[x][y] += grid[x - 1][y]; } } for (int x = 0; x < h + 2; ++x) { for (int y = 1; y < w + 2; ++y) { grid[x][y] += grid[x][y - 1]; } } for (int x = 1; x < h + 2; ++x) { for (int y = 0; y < w + 2; ++y) { grid[x][y] += grid[x - 1][y]; } } int ans = 0; for (auto [lx, rx, ly, ry, t] : slimes) { auto sum = grid[rx][ry] - grid[rx][ly - 1] - grid[lx - 1][ry] + grid[lx - 1][ly - 1]; if (sum < t) ++ans; } cout << ans << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }