#include <iostream> using namespace std; void rc(int v,int mn,int mx){if(v<mn||mx<v){cerr<<"error"<<endl;exit(1);}} const int OFFSET = 500; const int SIZE = 1555; int h[SIZE][SIZE]; int d[SIZE][SIZE]; int main(){ int N, K; cin >> N >> K; rc(N, 1, 100000); rc(K, 1, 100000); for(int i=0;i<N;i++){ int X, Y, H; cin >> X >> Y >> H; rc(X, -500, 500); rc(Y, -500, 500); rc(H, 1, 10000); X += OFFSET; Y += OFFSET; h[Y][X] = H; } for(int i=0;i<K;i++){ int AX, AY, W, H, D; cin >> AX >> AY >> W >> H >> D; rc(AX, -500, 500); rc(AY, -500, 500); rc(W, 1, 500); rc(H, 1, 500); rc(D, 1, 10000); AX += OFFSET; AY += OFFSET; d[AY][AX] += D; d[AY][AX+W+1] -= D; d[AY+H+1][AX] -= D; d[AY+H+1][AX+W+1] += D; } for(int Y=0;Y<SIZE;Y++){ for(int X=1;X<SIZE;X++){ d[Y][X] += d[Y][X-1]; } } for(int X=0;X<SIZE;X++){ for(int Y=1;Y<SIZE;Y++){ d[Y][X] += d[Y-1][X]; } } int res = 0; for(int Y=0;Y<SIZE;Y++)for(int X=0;X<SIZE;X++){ int rest = h[Y][X] - d[Y][X]; if(rest > 0)res += rest; } cout << res << endl; return 0; }