#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(), (x).rend() #define rep(i,n) for(int i=0;i P; typedef vector > pii; typedef map mi; const int N = 500; int hp[1001][1001]; int dmg[1001][1001]; int main(){ int n,k,sum=0; cin >> n >> k; rep(i,n){ int x,y,h; cin >> x >> y >> h; hp[N+y][N+x] = h; } rep(i,k){ int x,y,w,h,d; cin >> x >> y >> w >> h >> d; dmg[N+y][N+x] +=d; if(N+y+h+1<=1000) dmg[N+y+h+1][N+x] -=d; if(N+x+w+1<=1000) dmg[N+y][N+x+w+1] -=d; if(N+y+h+1<=1000 && N+x+w+1 <=1000) dmg[N+y+h+1][N+x+w+1] +=d; } rep(y,1001){ rep(x,1000){ dmg[y][x+1] += dmg[y][x]; } } 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; }