M=524 s=[[0]*M*4for _ in[0]*M*4] f=lambda:map(int,input().split()) n,k=f() E=[f()for _ in[0]*n] for i in[-M]*k: x,y,w,h,d=f() for j in[0,5,9,M]:s[x+j%-3*~w][y+j%-5*~h]+=d*(-1)**j while iM;j+=1-(j>M)*2*M print(sum(max(h-s[x][y],0)for x,y,h in E))