#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
long long n, m, i, j, x[50001], y[50001], p, a, q[50001], sum[50001], ans=0, k, b, sum1, u[50001];
pair <long, long> P[50001];
int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p >> x[0] >> q[0];
	sum[0] = a;
	for (i = 1; i < n; i++) {
		cin >>x[i]>>q[i];
		sum[i] = sum[i-1] + q[i];
	}
	sum1 = sum[n - 1];
	for (i = 0; i < m; i++) {
		cin >> y[i] >> P[i].second >> P[i].first;
	}
	if (p==0) {
		sort(P, P + m);
		i = m - 1;
		while (sum1 > 0 && i >= 0) {
			a = P[i].second;
			b = P[i].first;
			ans += min(a, sum1)*b;
			sum1 -= min(a, sum1);
			i--;
		}
		cout << ans;
		return 0;
	}
	j = m - 1;
	k = 0;
	if (x[0]>y[m-1]) {
		for (i = 0; i < n; i++) {
			if (i==0) {
				k = -1*x[0] * p;
			}
			else {
				k = -1*(x[i] - x[i - 1])*p;
			}
			sum1 = q[i];
			while (j >= 0&&sum1>0) {
				a = P[j].second;
				b = P[j].first;
				k += min(sum1, a)*b;
				P[j].second-= min(sum1, a);
				sum1 -= min(sum1, a);
				if (sum1>0) {
					j--;
				}
			}
			if (i == 0) {
				u[0] = k;
			}
			else {
				u[i] = u[i - 1] + k;
			}
		}
		for (i = 0; i < n; i++) {
			if (u[i]>ans) {
				ans = u[i];
			}
		}
		cout << ans;
		return 0;
	}
}
