#include "bits/stdc++.h" #define ALL(obj) (obj).begin(),(obj).end() #define RALL(obj) (obj).rbegin(),(obj).rend() #define REP(i, n) for(int i = 0; i < (int)(n); i++) #define REPR(i, n) for(int i = (int)(n); i >= 0; i--) #define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++) using namespace std; typedef long long ll; const int MOD = 1e9 + 7; const int INF = MOD - 1; const ll LLINF = 4e18; int main() { int n, k; cin >> n >> k; vector> grid(1502, vector(1502,0)); REP(i, n) { int x, y, hp; cin >> x >> y >> hp; grid[x + 500][y + 500] += hp; } REP(i, k) { int ax, ay, w, h, d; cin >> ax >> ay >> w >> h >> d; grid[ax + 500][ay + 500] -= d; grid[ax + w + 501][ay + h + 501] -= d; grid[ax + w + 501][ay + 500] -= d; grid[ax + 500][ay + h + 501] -= d; } REP(i, 1502) { FOR(j, 1, 1502) { grid[i][j] += grid[i][j - 1]; } } REP(i, 1502) { FOR(j, 1, 1502) { grid[j][i] += grid[j - 1][i]; } } cout << max(0LL,grid[1501][1501]) << endl; getchar(); getchar(); }