#include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; ll imos[2005][2005]; ll cumsum[2005][2005]; int h, w, n, m; int t[2005], u[2005], l[2005], r[2005]; ll a[2005]; void print(); void input(){ cin >> h >> w >> n >> m; for(int i = 0; i < n; i++) { cin >> t[i] >> u[i] >> l[i] >> r[i] >> a[i]; } for(int i = 0; i < m; i++){ int x, y, b, c; cin >> x >> y >> b >> c; int x1 = max(0, x-b); int x2 = min(h, x+b); int y1 = max(0, y-b); int y2 = min(w, y+b); imos[x1][y1]+=c; imos[x1][y2+1]-=c; imos[x2+1][y1]-=c; imos[x2+1][y2+1]+=c; } for(int i = 1; i <= h; i++){ for(int j = 0; j <= w; j++) imos[i][j] += imos[i-1][j]; } for(int i = 0; i <= h; i++){ for(int j = 1; j <= w; j++) imos[i][j] += imos[i][j-1]; } for(int i = 1; i <= h; i++){ for(int j = 1; j <= w; j++) { cumsum[i][j] = cumsum[i][j-1]+cumsum[i-1][j]-cumsum[i-1][j-1]+imos[i][j]; } } } ll calc(int t, int u, int l, int r){ return cumsum[u][r]-cumsum[u][l-1]-cumsum[t-1][r]+cumsum[t-1][l-1]; } void print(){ for(int i = 0; i <= h; i++){ for(int j = 0; j <= w; j++){ cout << imos[i][j] << ' '; } cout << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; input(); int ans = 0; for(int i = 0; i < n; i++){ ll x = calc(t[i], u[i], l[i], r[i]); if(x < a[i]) ans++; } cout << ans << endl; }