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++) { for (int y = AY[i]; y <= AY[i]+H[i]; y++) { if(1000 < y) continue; for (int x = AX[i]; x <= AX[i]+W[i]; x++) { if(1000 < x) continue; damage[y][x] += D[i]; } } } 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(); } }