#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:512000000")
#include <iostream>
#include <algorithm>


typedef long long ll;


using namespace std;


#define TASK "fisher"


ll x[50005];
ll a[50005];


struct shop {
	ll x, mx, c;


	shop() {}
} shops[50005];


int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif // _DEBUG
	int n, m, p;
	cin >> n >> m >> p;

//костыль
	if (p == 0) {
		ll fish = 0;
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> a[i];
			fish += a[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> shops[i].x >> shops[i].mx >> shops[i].c;
		}
		sort(shops, shops + m, [](shop a, shop b) { return a.c > b.c; });
		ll ans = 0;
		for (int i = 0; i < m; i++) {
			if (fish == 0) {
				break;
			}
			ans += min(fish, shops[i].mx) * shops[i].c;
			fish -= min(fish, shops[i].mx);
		}
		cout << ans;
		return 0;
	}
//костыль
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> shops[i].x >> shops[i].mx >> shops[i].c;
	}
	sort(shops, shops + m, [](shop a, shop b) { return a.c > b.c; });
	ll fish = 0;
	int q = 0;
	ll ans = 0;
	ll fi = 0;
	for (int i = 0; i < n; i++) {
		fish = a[i];
		ll fuel = x[i] * p;
		while (q < m && fish > 0) {
			fi += min(fish, shops[q].mx) * shops[q].c;
			fish -= min(fish, shops[q].mx);
			shops[q].mx -= min(fish, shops[q].mx);
			if (shops[q].mx == 0) {
				q++;
			}
		}
		ans = max(ans, fi - fuel);
	}
	cout << ans;
}