#include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,j) FOR(i,0,j) #define mp std::make_pair typedef long long ll; typedef unsigned long long ull; typedef std::pair P; typedef std::pair State; const int INF = 1001001001; // S N E W(南北東西) const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1}; int N, K; int enemyX[100000], enemyY[100000]; ll enemyH[100000]; ll map[2002][2002]; P adjust(const int &x, const int &y){ return mp(x + 1000, y + 1000); } int main(){ std::cin >> N >> K; REP(i, N){ std::cin >> enemyX[i] >> enemyY[i] >> enemyH[i]; } REP(i, K){ int x, y, w, h, d; std::cin >> x >> y >> w >> h >> d; P p = adjust(x, y), q = adjust(x+w, y+h); map[p.first][p.second] += d; map[p.first][q.second+1] -= d; map[q.first+1][p.second] -= d; map[q.first+1][q.second+1] += d; } REP(i, 2002){ FOR(j, 1, 2002){ map[j][i] += map[j-1][i]; } } REP(i, 2002){ FOR(j, 1, 2002){ map[i][j] += map[i][j-1]; } } ll res = 0ll; REP(i, N){ P p = adjust(enemyX[i], enemyY[i]); res += std::max(1ll * enemyH[i] - map[p.first][p.second], 0ll); } std::cout << res << std::endl; }