N, K = map(int, input().split()) XY = [list(map(int, input().split())) for _ in range(N)] AXY = [list(map(int, input().split())) for _ in range(K)] r = 500 + 1 r2 = r * 2 + 2 M = [[0] * r2 for _ in range(r2)] for x, y, w, h, d in AXY: x += r y += r M[x - 1][y - 1] += d if x + w < r2: M[x + w][y - 1] -= d if y + h < r2: M[x + w][y + h] += d if y + h + 1 < r2: M[x - 1][y + h] -= d for i in range(r2): for j in range(r2): if i > 0: M[i][j] += M[i - 1][j] if j > 0: M[i][j] -= M[i - 1][j - 1] if j > 0: M[i][j] += M[i][j - 1] ans = 0 for x, y, h in XY: ans += max(0, h - M[x + r - 1][y + r -1]) print(ans)