#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<queue>

#pragma warning (disable:4996)

#define ll long long int
#define mp make_pair

using namespace std;

ll n, m, p, x[500005], a[500005], y[500005], c[500005], b[500005];
pair<ll, ll> pp[500005];
map<ll, ll > mm;
map<ll, ll >::iterator it;

void solve() {
	ll i, j, sum, ans, q,maxi,t;
	for (i = 0; i < n; i++) {
		scanf("%I64d%I64d", &x[i], &a[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%I64d%I64d%I64d", &y[i], &b[i], &c[i]);
	}
	if (p == 0) {
		sum = 0;
		ans = 0;
		for (i = 0; i < n; i++) {
			sum += a[i];
		}
		for (i = 0; i < m; i++) {
			pp[i] = mp(c[i], b[i]);
		}
		sort(pp, pp + m);
		for (i = 0; i < m; i++) {
			q = min(sum, pp[i].second);
			ans += q*pp[i].first;
			sum -= q;
		}
		printf("%I64d", ans);
	}
	else {
		for (i = 0; i < m; i++) {
			mm[c[i]] += b[i];
		}
		ans = 0;
		maxi = 0;
		for (i = 0; i < n&&mm.size()>0; i++) {
			if (i != 0) {
				ans -= (x[i] - x[i - 1]) * p;
			}
			else {
				ans -= x[i] * p;
			}
			t = 0;
			while (mm.size() > 0 && t==0) {
				it = mm.end();
				it = prev(it);
				if (it->second > a[i]) {
					it->second -= a[i];
					ans += a[i] * it->first;
					a[i] = 0;
				}
				else {
					a[i] -= it->second;
					ans += it->second*it->first;
					mm.erase(it);
				}
				if (a[i] == 0) {
					t = 1;
				}
			}
			maxi = max(maxi, ans);
		}
		printf("%I64d", maxi);
	}
	return;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	freopen("fisher.in", "rt", stdin);
	freopen("fisher.out", "wt", stdout);
#endif
	scanf("%I64d%I64d%I64d", &n, &m, &p);
	solve();
	return 0;
}