#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

const int MAXN = 51000;
long long x[MAXN], y[MAXN], a[MAXN], b, c;
long long suma = 0;

vector <pair <long long, long long> > d;
vector <pair <long long, pair <long long, long long>>> d1;
set <long long> k;

int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p;
	cin >> n >> m >> p;
	for (int i = 0; i < n; i++) {
		scanf_s("%d%d", &x[i], &a[i]);
		suma += a[i];
		k.insert(x[i]);
	}
	for (int i = 0; i < m; i++) {
		scanf_s("%d%d%d", &y[i], &b, &c);
		d.push_back(make_pair(-c, b));
		d1.push_back(make_pair(-c, make_pair(b, y[i])));
		k.insert(y[i]);
	}
	
	if (p == 0) {
		sort(d.begin(), d.end());
		int ind = 0;
		long long ans = 0;
		while (suma != 0 && ind < m) {
			if (d[ind].second <= suma) {
				ans += d[ind].second * (-d[ind].first);
				suma -= d[ind].second;
			}
			else {
				ans += suma * (-d[ind].first);
				suma = 0;
			}
			ind++;
		}
		cout << ans;
	}
	else {
		sort(d1.begin(), d1.end());
		long long ans1 = 0;
		if (max(n, m) < 10000) {
			set <long long> ::iterator it = k.begin();
			for (it = k.begin(); it != k.end(); it++) {
				suma = 0;
				for (int i = 0; i < n; i++) {
					if (x[i] <= (*it)) {
						suma += a[i];
					}
				}
				int ind = 0;
				long long ans = 0;
				while (suma != 0 && ind < m) {
					if (d1[ind].second.second <= (*it)) {
						if (d1[ind].second.first <= suma) {
							ans += d1[ind].second.first * (-d1[ind].first);
							suma -= d1[ind].second.first;
						}
						else {
							ans += suma * (-d1[ind].first);
							suma = 0;
						}
					}
					ans1 = max(ans1, ans - p * (*it));
					ind++;
				}
				
			}
			cout << ans1;
		}
	}
	return 0;
}
/*
3 3 10
1 1
10 100
20 10
2 1000 1
11 50 50
17 50 2

*/