import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): N, K = getlist() table = [[0] * 1002 for i in range(1002)] for i in range(N): X, Y, HP = getlist() X += 500; Y += 500 table[X][Y] += HP imostable = [[0] * 1002 for i in range(1002)] for i in range(K): X, Y, W, H, D = getlist() X += 500; Y += 500 xp = min(X + W + 1, 1001) yp = min(Y + H + 1, 1001) imostable[X][Y] -= D imostable[xp][Y] += D imostable[X][yp] += D imostable[xp][yp] -= D # 二次元imos累積和 for i in range(1002): for j in range(1001): imostable[i][j + 1] += imostable[i][j] for i in range(1001): for j in range(1002): imostable[i + 1][j] += imostable[i][j] # test = 0 # for i in range(1002): # test += sum(imostable[i]) # print(test) ans = 0 for i in range(1001): for j in range(1001): ans += max(0, imostable[i][j] + table[i][j]) print(ans) if __name__ == '__main__': main()