#include using namespace std; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, K; cin >> N >> K; vector> V(N); for (int i = 0; i < N; i++) { int x, y, hp; cin >> x >> y >> hp; V.at(i) = {x + 500, y + 500, hp}; } N = 1502; vector DP(N, vector(N, 0)); for (int i = 0; i < K; i++) { int x, y, w, h, d; cin >> x >> y >> w >> h >> d; x += 500, y += 500; DP.at(x).at(y) += d; DP.at(x + w + 1).at(y) -= d; DP.at(x).at(y + h + 1) -= d; DP.at(x + w + 1).at(y + h + 1) += d; } for (int i = 0; i < N; i++) { for (int j = 0; j + 1 < N; j++) { DP.at(i).at(j + 1) += DP.at(i).at(j); } } for (int i = 0; i + 1 < N; i++) { for (int j = 0; j < N; j++) { DP.at(i + 1).at(j) += DP.at(i).at(j); } } long ans = 0; for (auto [x, y, hp] : V) { ans += max(0, hp - DP.at(x).at(y)); } cout << ans << "\n"; }