#include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define RREP(i, n) for(int(i)=(n)-1;(i)>=0;--(i)) const int MOD = (int)(1e9+9); const int B = 500; ll HP[1001][1001]; ll DMG[1001][1001]; int main(){ int N,K; cin >> N >> K; REP(i,N){ int X,Y,H; cin >> X >> Y >> H; HP[B+Y][B+X] = H; } REP(i,K){ int x,y,w,h,d; cin >> x >> y >> w >> h >> d; DMG[B+y][B+x] += d; if(B+y+h+1<=1000) DMG[B+y+h+1][B+x] -= d; if(B+x+w+1<=1000) DMG[B+y][B+x+w+1] -= d; if(B+y+h+1<=1000 && B+x+w+1 <= 1000) DMG[B+y+h+1][B+x+w+1] += d; } REP(y,1001) REP(x,1000){ DMG[y][x+1] += DMG[y][x]; } int sum = 0; REP(y,1001) REP(x,1001){ if(y < 1000) DMG[y+1][x] += DMG[y][x]; if(HP[y][x] > DMG[y][x]){ sum += HP[y][x]-DMG[y][x]; } } cout << sum << endl; return 0; }