import java.util.ArrayList; import java.util.HashSet; import java.util.Scanner; import java.util.TreeSet; public class Main { static int N, K; static int[] X, Y, HP; static int[] AX, AY, W, H, D; public static int solve(){ int[][] damage = new int[1001][1001]; for (int y = 0; y < 1001; y++) { for (int x = 0; x < 1001; x++) { damage[y][x] = 0; } } for (int i = 0; i < K; i++) { int x = AX[i], y = AY[i]; damage[y][x] += D[i]; if(x + W[i] + 1 <= 1000) { damage[y][x+W[i]+1] += -1 * D[i]; if(y+H[i]+1 <= 1000) { damage[y+H[i]+1][x+W[i]+1] += D[i]; } } if(y+H[i]+1 <= 1000) { damage[y+H[i]+1][x] += -1 * D[i]; } } for (int y = 0; y <= 1000; y++) { for (int x = 1; x <= 1000; x++) { damage[y][x] += damage[y][x-1]; } } for (int x = 0; x <= 1000; x++) { for (int y = 1; y <= 1000; y++) { damage[y][x] += damage[y-1][x]; } } int ret = 0; for (int i = 0; i < N; i++) { int delta = HP[i] - damage[Y[i]][X[i]]; if(delta > 0) ret += delta; } System.out.println(ret); return 0; } public static void main(String[] args){ Scanner S = new Scanner(System.in); N = S.nextInt(); K = S.nextInt(); X = new int[N]; Y = new int[N]; HP = new int[N]; for (int i = 0; i < N; i++) { X[i] = S.nextInt() + 500; Y[i] = S.nextInt() + 500; HP[i] = S.nextInt(); } AX = new int[K]; AY = new int[K]; W = new int[K]; H = new int[K]; D = new int[K]; for (int i = 0; i < K; i++) { AX[i] = S.nextInt() + 500; AY[i] = S.nextInt() + 500; W[i] = S.nextInt(); H[i] = S.nextInt(); D[i] = S.nextInt(); } solve(); } }