#include #define rep(i, a) for (int i = 0; i < (a); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) for (int i = (a) - 1; i >= 0; i--) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; int N, K; int X[100000], Y[100000], HP[100000]; const int offset = 1010; ll imos[2020][2020]; int main() { cin >> N >> K; rep (i, N) { cin >> X[i] >> Y[i] >> HP[i]; X[i] += offset; Y[i] += offset; } rep (i, K) { int x, y, w, h, d; cin >> x >> y >> w >> h >> d; x += offset; y += offset; imos[y][x] += d; imos[y + h + 1][x] -= d; imos[y][x + w + 1] -= d; imos[y + h + 1][x + w + 1] += d; } rep (i, 2020) { rep (j, 2020 - 1) { imos[i][j + 1] += imos[i][j]; } } rep (j, 2020) { rep (i, 2020 - 1) { imos[i + 1][j] += imos[i][j]; } } ll ans = 0; rep (i, N) { ans += max(0, HP[i] - imos[Y[i]][X[i]]); } cout << ans << endl; }