import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] xArr = new int[n]; int[] yArr = new int[n]; int[] hArr = new int[n]; for (int i = 0; i < n; i++) { xArr[i] = sc.nextInt() + 501; yArr[i] = sc.nextInt() + 501; hArr[i] = sc.nextInt(); } int[][] imos = new int[1010][1010]; for (int i = 0; i < k; i++) { int x = sc.nextInt() + 501; int y = sc.nextInt() + 501; int w = sc.nextInt(); int h = sc.nextInt(); int d = sc.nextInt(); imos[x][y] += d; imos[Math.min(x + w + 1, 1009)][y] -= d; imos[x][Math.min(y + h + 1, 1009)] -= d; imos[Math.min(x + w + 1, 1009)][Math.min(y + h + 1, 1009)] += d; } for (int i = 1; i < 1010; i++) { for (int j = 1; j < 1010; j++) { imos[i][j] += imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1]; } } long ans = 0; for (int i = 0; i < n; i++) { ans += Math.max(0, hArr[i] - imos[xArr[i]][yArr[i]]); } System.out.println(ans); } }