import sys import numpy as np input = sys.stdin.readline N, K = map(int, input().split()) enemies = [[0] * 1002 for _ in range(1002)] damages = [[0] * 1002 for _ in range(1002)] for _ in range(N): x, y, hp = map(int, input().split()) enemies[y + 500][x + 500] = hp enemies = np.array(enemies) for _ in range(K): ax, ay, w, h, d = map(int, input().split()) ax += 500 ay += 500 axw = min(ax + w + 1, 1001) ayh = min(ay + h + 1, 1001) damages[ay][ax] += d damages[ayh][ax] -= d damages[ay][axw] -= d damages[ayh][axw] += d damages = np.array(damages) np.cumsum(damages, axis=0, out=damages) np.cumsum(damages, axis=1, out=damages) print(np.sum(np.maximum(enemies - damages, np.zeros_like(enemies, dtype=int))))