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 size = 1503; int[] xArr = new int[n]; int[] yArr = new int[n]; int[] hpArr = new int[n]; int[][] field = new int[size][size]; for (int i = 0; i < n; i++) { xArr[i] = sc.nextInt() + 500; yArr[i] = sc.nextInt() + 500; hpArr[i] = sc.nextInt(); } for (int i = 0; i < k; i++) { int x = sc.nextInt() + 500; int y = sc.nextInt() + 500; int w = sc.nextInt(); int h = sc.nextInt(); int hp = sc.nextInt(); field[x][y] += -hp; field[x + w + 1][y] += hp; field[x][y + h + 1] += hp; field[x + w + 1][y + h + 1] += -hp; } for (int i = 1; i < size; i++) { for (int j = 0; j < size; j++) { field[i][j] += field[i - 1][j]; } } for (int i = 1; i < size; i++) { for (int j = 0; j < size; j++) { field[j][i] += field[j][i - 1]; } } long sum = 0; for (int i = 0; i < n; i++) { if (field[xArr[i]][yArr[i]] + hpArr[i] > 0) { sum += field[xArr[i]][yArr[i]] + hpArr[i]; } } System.out.println(sum); } }