#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n,k; scanf("%d%d",&n,&k); vector x(n),y(n),hp(n); rep(i,n) scanf("%d%d%d",&x[i],&y[i],&hp[i]), x[i]+=1000, y[i]+=1000; static int sum[2001][2001]; rep(i,k){ int ax,ay,w,h,d; scanf("%d%d%d%d%d",&ax,&ay,&w,&h,&d); ax+=1000; ay+=1000; sum[ay][ax]+=d; sum[ay][ax+w+1]-=d; sum[ay+h+1][ax]-=d; sum[ay+h+1][ax+w+1]+=d; } rep(i,2001) rep(j,2000) sum[i][j+1]+=sum[i][j]; rep(i,2000) rep(j,2001) sum[i+1][j]+=sum[i][j]; int ans=0; rep(i,n) ans+=max(hp[i]-sum[y[i]][x[i]],0); printf("%d\n",ans); return 0; }