// yukicoder: No.60 魔法少女 // 2019.6.19 bal4u #include #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() // 整数の入力(負数対応) { int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } #define BASE 500 int X[100005], Y[100005], HP[100005]; int map[1005][1005]; int main() { int i, x, y, w, h, d, s, N, K; N = in(), K = in(); for (i = 0; i < N; i++) { X[i] = in() + BASE; Y[i] = in() + BASE; HP[i] = in(); } while (K--) { x = BASE + in(), y = BASE + in(); w = x + in() + 1, h = y + in() + 1, d = in(); if (w > 1001) w = 1001; if (h > 1001) h = 1001; map[y][x] += d; map[y][w] -= d; map[h][x] -= d; map[h][w] += d; } for (y = 0; y <= 1001; y++) for (x = 0; x <= 1001; x++) map[y][x+1] += map[y][x]; for (y = 0; y <= 1001; y++) for (x = 0; x <= 1001; x++) map[y+1][x] += map[y][x]; s = 0; for (i = 0; i < N; i++) { d = HP[i] - map[Y[i]][X[i]]; if (d > 0) s += d; } printf("%d\n", s); return 0; }