import sys def solve(): N, K = map(int, sys.stdin.readline().split()) teki = dict() for i in range(N): x, y, hp = map(int, sys.stdin.readline().split()) x += 500 y += 500 teki[(y, x)] = hp kougeki = [[0] * (1000 + 1) for i in range(1000 + 1)] for i in range(K): ax, ay, w, h, d = map(int, sys.stdin.readline().split()) ax += 500 ay += 500 kougeki[ay][ax] += d if ax + w + 1 < 1000 + 1: kougeki[ay][ax + w + 1] -= d if ay + h + 1 < 1000 + 1: kougeki[ay + h + 1][ax] -= d if ax + w + 1 < 1000 + 1 and ay + h + 1 < 1000 + 1: kougeki[ay + h + 1][ax + w + 1] += d for i in range(1000 + 1): for j in range(1000): kougeki[i][j + 1] += kougeki[i][j] for j in range(1000 + 1): for i in range(1000): kougeki[i + 1][j] += kougeki[i][j] ans = 0 for (y, x), hp in teki.items(): ans += max(0, hp - kougeki[y][x]) print(ans) if __name__ == '__main__': solve()