// #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; using namespace atcoder; using mint = modint998244353; // using mint = modint1000000007; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair; using pll = pair; using T = tuple; using G = vector>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, a, b) for (ll i = a; i < (b); ++i) #define rrep2(i, a, b) for (ll i = a-1; i >= (b); --i) #define rep3(i, a, b, c) for (ll i = a; i < (b); i+=c) #define rng(a) a.begin(),a.end() #define rrng(a) a.rbegin(),a.rend() #define popcount __builtin_popcount #define popcountll __builtin_popcountll #define fi first #define se second #define UNIQUE(v) sort(rng(v)), v.erase(unique(rng(v)), v.end()) #define MIN(v) *min_element(rng(v)) #define MAX(v) *max_element(rng(v)) #define SUM(v) accumulate(rng(v),0) #define IN(v, x) (find(rng(v),x) != v.end()) template bool chmin(T &a,T b){if(a>b){a=b;return 1;}else return 0;} template bool chmax(T &a,T b){if(a void printv(vector &v){rep(i,v.size())cout<> n >> k; vector dp(2000, vector(2000, 0)); vector query; rep(i, n){ int x, y, h; cin >> x >> y >> h; x += m, y += m; query.emplace_back(x, y, h); } rep(i, k){ int x, y, w, h, d; cin >> x >> y >> w >> h >> d; x += m, y += m; dp[x][y] += d; dp[x+w+1][y] -= d; dp[x][y+h+1] -= d; dp[x+w+1][y+h+1] += d; } rep(i, 1001)rep(j, 1001){ dp[i][j+1] += dp[i][j]; } rep(i, 1001)rep(j, 1001){ dp[i+1][j] += dp[i][j]; } ll ans = 0; for (auto [x, y, h]: query){ if (h-dp[x][y] > 0) ans += h-dp[x][y]; } cout << ans << endl; return 0; }