## implementation

#include <cstdio>
#include <vector>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int size   = 1001;
const int offset = 500;
int main() {
int n, k; scanf("%d%d", &n, &k);
vector<int> x(n), y(n), hp(n); repeat (i,n) scanf("%d%d%d", &x[i], &y[i], &hp[i]);
vector<int> ax(k), ay(k), w(k), h(k), d(k); repeat (i,k) scanf("%d%d%d%d%d", &ax[i], &ay[i], &w[i], &h[i], &d[i]);
array<array<ll,size+1>,size+1> imos = {};
repeat (i,k) {
int lx = ax[i] + offset;
int ly = ay[i] + offset;
int rx = min(size, ax[i] + offset + w[i] + 1);
int ry = min(size, ay[i] + offset + h[i] + 1);
imos[ly][lx] += d[i];
imos[ly][rx] -= d[i];
imos[ry][lx] -= d[i];
imos[ry][rx] += d[i];
}
repeat (y,size+1) repeat (x,size) imos[y][x+1] += imos[y][x];
repeat (x,size+1) repeat (y,size) imos[y+1][x] += imos[y][x];
ll ans = 0;
repeat (i,n) {
ans += max(0ll, hp[i] - imos[y[i] + offset][x[i] + offset]);
}
printf("%lld\n", ans);
return 0;
}