#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } ll HP[1005][1005], S[1005][1005]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N, K, W, H, D; cin >> N >> K; vector X(N), Y(N); for(int i = 0; i < N; ++i){ cin >> X[i] >> Y[i]; X[i] += 500; Y[i] += 500; cin >> HP[X[i]][Y[i]]; } for(int q = 0; q < K; ++q){ int x, y; cin >> x >> y >> W >> H >> D; x += 500; y += 500; S[x][y] += D; S[x][min(1000, y + H) + 1] -= D; S[min(1000, x + W) + 1][y] -= D; S[min(1000, x + W) + 1][min(1000, y + H) + 1] += D; } for(int x = 0; x <= 1000; ++x){ for(int y = 0; y <= 1000; ++y){ S[x][y + 1] += S[x][y]; } } for(int y = 0; y <= 1000; ++y){ for(int x = 0; x <= 1000; ++x){ S[x + 1][y] += S[x][y]; } } ll ans = 0; for(int i = 0; i < N; ++i){ ans += max(0LL, HP[X[i]][Y[i]] - S[X[i]][Y[i]]); } cout << ans << endl; return 0; }