#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
const long long N = (long long)1e5 + 113;

long long n, m, p, ans, totalFish, cost, canSell, currCost, ind = 1;
long long x[N], y[N], b[N], c[N], a[N];
multiset <pair <long long, long long> > st;
vector <pair <long long, long long>> vec;
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("outputGood.txt", "w", stdout);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);

	cin >> n >> m >> p;


	for (long long i = 1; i <= n; i++) {
		cin >> x[i] >> a[i];
	}
	for (long long i = 1; i <= m; i++) {
		cin >> y[i] >> b[i] >> c[i];
	}

	if (p == 0) {
		for (int i = 1; i <= n; i++) {
			totalFish += a[i];
		}
		for (int i = 1; i <= m; i++) {
			vec.push_back(make_pair(c[i], b[i]));
		}
		sort(vec.begin(), vec.end());

		for (int i = vec.size() - 1; i >= 0; i--) {
			canSell = min(totalFish, vec[i].second);
			ans += canSell * vec[i].first;
			totalFish -= canSell;
			if (totalFish == 0)
				break;
		}
		cout << ans;
		return 0;
	}
	if (y[m] < x[1]) {

		for (int i = 1; i <= m; i++) {
			vec.push_back(make_pair(c[i], b[i]));
		}
		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());
		ind = 0;
		for (int i = 1; i <= n; i++) {
			long long have = a[i];
			while (have && ind < m) {
				canSell = min(vec[ind].second, have);
				currCost += canSell * vec[ind].first;
				vec[ind].second -= canSell;
				if (vec[ind].second == 0)
					ind++;
				have -= canSell;
			}
			cost = currCost - x[i] * p;
			ans = max(ans, cost);
		}
		cout << ans;
		return 0;
	}
	for (long long i = 1; i <= n; i++) {
		totalFish += a[i];
		while (ind <= m && y[ind] <= x[i]) {
			st.insert(make_pair(-c[ind], b[ind]));
			ind++;
		}

		long long lastfist = totalFish;
		currCost = 0;
		for (set <pair <long long, long long> > ::iterator it = st.begin(); it != st.end(); it++) {
			canSell = min(lastfist, it->second);
			currCost -= it->first * canSell;
			lastfist -= canSell;
		}
		cost = currCost - x[i] * p;
		ans = max(ans, cost);
	}
	totalFish = 0;
	ind = 1;
	st.clear();
	for (long long i = 1; i <= m; i++) {
		while (ind <= n && x[ind] <= y[i]) {
			totalFish += a[ind];
			ind++;
		}

		st.insert(make_pair(-c[i], b[i]));

		long long lastfist = totalFish;
		currCost = 0;
		for (set <pair <long long, long long> > ::iterator it = st.begin(); it != st.end(); it++) {
			canSell = min(lastfist, it->second);
			currCost -= it->first * canSell;
			lastfist -= canSell;
		}
		cost = currCost - y[i] * p;
		ans = max(ans, cost);
	}

	cout << ans;
}