#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int MA = 100001, R = 1510, OFF = 500; int X[MA], Y[MA], HP[MA]; ll atk[R][R]; int main(){ int N, K; cin >> N >> K; rep(i, N){ scanf("%d%d%d", &X[i], &Y[i], &HP[i]); X[i] += OFF; Y[i] += OFF; } rep(i, K){ int ax, ay, w, h, d; scanf("%d%d%d%d%d", &ax, &ay, &w, &h, &d); ax += OFF; ay += OFF; w++; h++; atk[ax][ay] += d; atk[ax + w][ay] -= d; atk[ax][ay + h] -= d; atk[ax + w][ay + h] += d; } rep(i, R - 1)rep(j, R)atk[i + 1][j] += atk[i][j]; rep(i, R)rep(j, R - 1)atk[i][j + 1] += atk[i][j]; ll ans = 0; rep(i, N){ ll hp = HP[i] - atk[X[i]][Y[i]]; if(hp > 0)ans += hp; } cout << ans << endl; }