import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); int[] xs = new int[n]; int[] ys = new int[n]; int[] hs = new int[n]; for (int i = 0; i < n; i++) { xs[i] = sc.nextInt() + 501; ys[i] = sc.nextInt() + 501; hs[i] = sc.nextInt(); } int[][] imos = new int[1003][1003]; 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, 1002)][y] -= d; imos[x][Math.min(y + h + 1, 1002)] -= d; imos[Math.min(x + w + 1, 1002)][Math.min(y + h + 1, 1002)] += d; } for (int i = 1; i < 1003; i++) { for (int j = 1; j < 1003; 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, hs[i] - imos[xs[i]][ys[i]]); } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }