//ばぐらせごみ #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; typedef vector vl; typedef pair pll; typedef vector > vpll; typedef vector vs; typedef long double ld; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } int main() { const int T = 500, T2 = T * 2 + 1; int N, K; scanf("%d%d", &N, &K); vector > Hs(T2, vi(T2, -1)); rep(i, N) { int X, Y, H; scanf("%d%d%d", &X, &Y, &H); Hs[Y + T][X + T] = H; } vector > cumsum(T2+1, vector(T2+1, 0)); rep(i, K) { int AX, AY, W, H, D; scanf("%d%d%d%d%d", &AX, &AY, &W, &H, &D); int top = max(0, AY + T); int left = max(0, AX + T); int bottom = max(0,min(AY + H + 1 + T, T2)); int right = max(0,min(AX + W + 1 + T, T2)); cumsum[ top][left] += +D; cumsum[ top][right] += -D; cumsum[bottom][left] += -D; cumsum[bottom][right] += +D; } rep(i, T2+1) rep(j, T2) cumsum[i][j+1] += cumsum[i][j]; rep(i, T2) rep(j, T2+1) cumsum[i+1][j] += cumsum[i][j]; ll ans = 0; rep(i, T2) rep(j, T2) { int h = Hs[i][j]; // if(h!=-1||cumsum[i][j]) cerr << i-T << ", " << j-T << ": " <