#include using namespace std; struct slime { long long t, u, l, r, a; slime(long long _t = 0, long long _u = 0, long long _l = 0, long long _r = 0, long long _a = 0) : t(_t), u(_u), l(_l), r(_r), a(_a) {} }; long long h, w, n, m; vector v; vector> sum; int solve(); int main() { cin >> h >> w >> n >> m; v.resize(n); for (auto &[t, u, l, r, a] : v) cin >> t >> u >> l >> r >> a, --t, --l, --u, --r; sum.assign(h + 1, vector(w + 1, 0)); for (int i = 0; i < m; ++i) { long long x, y, b, c, t, u, l, r; cin >> x >> y >> b >> c, --x, --y; t = max(0LL, x - b), u = min(h, x + b + 1); l = max(0LL, y - b), r = min(w, y + b + 1); sum[t][l] += c, sum[t][r] -= c, sum[u][l] -= c, sum[u][r] += c; } cout << solve() << endl; return 0; } int solve() { int res = 0; for (int i = 0; i <= h; ++i) for (int j = 1; j <= w; ++j) sum[i][j] += sum[i][j - 1]; for (int i = 1; i <= h; ++i) for (int j = 0; j <= w; ++j) sum[i][j] += sum[i - 1][j]; for (int i = 0; i <= h; ++i) for (int j = 0; j <= w; ++j) { if (j) sum[i][j] += sum[i][j - 1]; if (i) sum[i][j] += sum[i - 1][j]; if (i && j) sum[i][j] -= sum[i - 1][j - 1]; } for (auto [t, u, l, r, a] : v) { long long now = sum[u][r]; if (t) now -= sum[t][r]; if (l) now -= sum[u][l]; if (t && l) now += sum[t][l]; if (now < a) ++res; } return res; }