#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

bool comp(pair< long long, pair<long long, long long> > p1, pair< long long, pair<long long, long long> > p2) {
	return p1.first > p2.first;
}

long long sum(vector< pair<long long, pair<long long, long long> > > &mark, long long cnt) {
	long long x = 0;
	for (long long i = 0; i < (long long)mark.size(); i++) {
		if (cnt == 0) {
			break;
		}
		if (mark[i].second.second <= 0) {
			continue;
		}
		if (cnt >= mark[i].second.first) {
			cnt -= mark[i].second.first;
			x += mark[i].second.first * mark[i].first;
		} else {
			x += cnt * mark[i].first;
			cnt = 0;
		}
	}
	return x;
}

int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	long long n, m, p;
	cin >> n >> m >> p;
	vector< pair<long long, long long> > fish(n, { 0, 0 }); //расстояние и ...
	for (long long i = 0; i < n; i++) {
		cin >> fish[i].first >> fish[i].second;
	}
	sort(fish.begin(), fish.end());
	vector< pair<long long, pair<long long, long long> > > mark;
	vector< pair<long long, long long> > md;
	for (long long i = 0; i < m; i++) {
		long long y, b, c;
		cin >> y >> b >> c;
		mark.push_back({ c, {b, -i} });
		md.push_back({ y, i });
	}
	sort(mark.begin(), mark.end(), comp);
	for (long long i = 0; i < (long long)mark.size(); i++) {
		long long v = -mark[i].second.second;
		md[v] = { md[v].first, i };
	}
	sort(md.begin(), md.end());
	long long k = 0, j = 0, cnt = 0, cost = 0, maxn = 0;
	while ((k < (long long)fish.size()) || (j < (long long)md.size())) {
		if ((k < (long long)fish.size()) && (j < (long long)md.size())) {

			if (fish[k].first <= md[j].first) {
				cost = p * fish[k].first;
				cnt += fish[k].second;
				long long x = sum(mark, cnt);
				maxn = max(maxn, x - cost);
				k++;
			} else {
				cost = p * md[j].first;
				mark[md[j].second].second.second = 1;
				long long x = sum(mark, cnt);
				maxn = max(maxn, x - cost);
				j++;
			}

		} else if (k < (long long)fish.size()) {

			cost = p * fish[k].first;
			cnt += fish[k].second;
			long long x = sum(mark, cnt);
			maxn = max(maxn, x - cost);
			k++;

		} else {

			cost = p * md[j].first;
			mark[md[j].second].second.second = 1;
			long long x = sum(mark, cnt);
			maxn = max(maxn, x - cost);
			j++;

		}
	}
	cout << maxn;
	return 0;
}