#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 1000000000 #define EPS 1e-9 #define PI acos(-1) typedef long long ll; typedef pair P; #define MAX_N 100000 #define MAX_K 100000 #define MAX_F 2000 int N, K; int X[MAX_N], Y[MAX_N], HP[MAX_N]; int AX[MAX_K], AY[MAX_K], W[MAX_K], H[MAX_K], D[MAX_K]; const int GETA = 600; int filed[MAX_F][MAX_F]; int main(){ cin >> N >> K; for(int i = 0; i < N; i++){ cin >> X[i] >> Y[i] >> HP[i]; X[i] += GETA; Y[i] += GETA; } for(int i = 0; i < K; i++){ cin >> AX[i] >> AY[i] >> W[i] >> H[i] >> D[i]; AX[i] += GETA; AY[i] += GETA; } //フィールドデータの設定 memset(filed,0,sizeof(filed)); for(int i = 0; i < K; i++){ filed[AX[i]][AY[i]] += D[i]; filed[AX[i]+W[i]+1][AY[i]] -= D[i]; filed[AX[i]][AY[i]+H[i]+1] -= D[i]; filed[AX[i]+W[i]+1][AY[i]+H[i]+1] += D[i]; } //横方向への累積和 for(int i = 1; i < MAX_F; i++){ for(int j = 0; j < MAX_F; j++){ filed[i][j] += filed[i-1][j]; } } //縦方向への累積和 for(int i = 0; i < MAX_F; i++){ for(int j = 1; j < MAX_F; j++){ filed[i][j] += filed[i][j-1]; } } int ans = 0; for(int i = 0; i < N; i++){ int tmp = HP[i] - filed[X[i]][Y[i]]; if(tmp > 0) ans += tmp; } cout << ans << endl; return 0; }