import java.io.*; import java.util.*; public class Main_yukicoder60 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); final int MAX = 1001; int n = sc.nextInt(); int k = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] hp = new int[n]; for (int i = 0; i < n; i++) { x[i] = sc.nextInt() + 500; y[i] = sc.nextInt() + 500; hp[i] = sc.nextInt(); } int[][] mat = new int[MAX + 1][MAX + 1]; for (int i = 0; i < k; i++) { int ax = sc.nextInt() + 500; int ay = sc.nextInt() + 500; int w = sc.nextInt(); int h = sc.nextInt(); int d = sc.nextInt(); mat[ay][ax] += d; mat[ay][Math.min(MAX, ax + w + 1)] -= d; mat[Math.min(MAX, ay + h + 1)][ax] -= d; mat[Math.min(MAX, ay + h + 1)][Math.min(MAX, ax + w + 1)] += d; } for (int i = 0; i <= MAX; i++) { for (int j = 1; j <= MAX; j++) { mat[i][j] += mat[i][j - 1]; } } for (int i = 1; i <= MAX; i++) { for (int j = 0; j <= MAX; j++) { mat[i][j] += mat[i - 1][j]; } } int ret = 0; for (int i = 0; i < n; i++) { int tmp = hp[i] - mat[y[i]][x[i]]; if (tmp > 0) { ret += tmp; } } pr.println(ret); // for (int i = 0; i <= MAX; i++) { // for (int j = 0; j <= MAX; j++) { // pr.print(mat[i][j]); // pr.print(" "); // } // pr.println(); // } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }