import numpy as np import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) U = 1000 N, K = map(int, input().split()) xyh = np.array([input().split() for _ in range(N)], dtype=np.int64) x, y, h, w, d = np.array([input().split() for _ in range(K)], dtype=np.int64).T x += U y += U G = np.zeros((2*U+2, 2*U+2), dtype=np.int64) np.add.at(G, (x, y), d) np.add.at(G, (x + h + 1, y), -d) np.add.at(G, (x, y + w + 1), -d) np.add.at(G, (x + h + 1, y + w + 1), d) np.cumsum(G, axis=0, out=G) np.cumsum(G, axis=1, out=G) x, y, h = xyh.T x += U y += U rest = h - G[x, y] rest[rest < 0] = 0 print(rest.sum())