#include using namespace std; using lint = long long; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> H >> W >> N >> M; vector> tulra; while (N--) { short t, u, l, r; int a; cin >> t >> u >> l >> r >> a; t--; l--; tulra.emplace_back(t, u, l, r, a); } vector cum(H + 2, vector(W + 2)); while (M--) { short x, y, b; int c; cin >> x >> y >> b >> c; short t = max(1, x - b) - 1; short u = min(H, x + b); short l = max(1, y - b) - 1; short r = min(W, y + b); cum[t + 1][l + 1] += c; cum[t + 1][r + 1] -= c; cum[u + 1][l + 1] -= c; cum[u + 1][r + 1] += c; } REP(_, 2) { REP(i, cum.size()) REP(j, cum[i].size() - 1) cum[i][j + 1] += cum[i][j]; REP(j, cum[0].size()) REP(i, cum.size() - 1) cum[i + 1][j] += cum[i][j]; } int ret = 0; for (auto [t, u, l, r, a] : tulra) { long long s = cum[t][l] - cum[t][r] - cum[u][l] + cum[u][r]; if (s < a) ret++; } cout << ret << '\n'; }