#include using namespace std; #define endl '\n' #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef pair P; typedef unsigned int uint; typedef unsigned long long ull; struct pairhash { public: template size_t operator()(const pair &x) const { size_t seed = hash()(x.first); return hash()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int inf = 1000000009; const double eps = 1e-8; ll board[1600][1600]; ll solve(int n, int k) { int buf = 500, s = 1600; int x[n], y[n]; ll hp[n]; for (int i = 0; i < n; i++) { int _x, _y; scanf("%d%d%lld", &_x, &_y, &hp[i]); x[i] = _x + buf; y[i] = _y + buf; } for (int i = 0; i < k; i++) { int ax, ay, w, h; ll d; scanf("%d%d%d%d%lld", &ax, &ay, &w, &h, &d); ax += buf; ay += buf; board[ay][ax] += d; board[ay+h+1][ax] -= d; board[ay][ax+w+1] -= d; board[ay+h+1][ax+w+1] += d; } for (int i = 0; i < s; i++) { for (int j = 1; j < s; j++) { board[i][j] += board[i][j-1]; } } for (int i = 1; i < s; i++) { for (int j = 0; j < s; j++) { board[i][j] += board[i-1][j]; } } ll res = 0; for (int i = 0; i < n; i++) { res += max(0LL, hp[i] - board[y[i]][x[i]]); } return res; } int main() { /* ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); */ int n, k; scanf("%d%d", &n, &k); printf("%lld\n", solve(n, k)); }