import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, k=map(int, readline().split()) myon=list(map(int, read().split())) xyh=myon[:3*n] awhd=myon[3*n:] s=[[0]*1002 for _ in range(1002)] for ax, ay, w, h, d in zip(*[iter(awhd)]*5): ax+=500 ay+=500 s[ax][ay]+=d bx, by=min(ax+w+1, 1001), min(ay+h+1, 1001) s[bx][ay]-=d s[ax][by]-=d s[bx][by]+=d for i in range(1001): for j in range(1000): s[i][j+1]+=s[i][j] for i in range(1000): for j in range(1001): s[i+1][j]+=s[i][j] ans=0 for x, y, h in zip(*[iter(xyh)]*3): x+=500 y+=500 ans+=max(0, h-s[x][y]) print(ans)