#include<fstream>
#include<algorithm>
#include<string>
#include<set>
#include<vector>

using namespace std;

typedef long long ll;
const int maxn = 500005;

ll n, m, p;
ll x[maxn], a[maxn], y[maxn], b[maxn], c[maxn];
set<pair<ll, ll> > mys;

int main() {
	ifstream cin("fisher.in");
	ofstream cout("fisher.out");
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> p;
	for (int i = 1; i <= n; ++i)
		cin >> x[i] >> a[i];
	for (int i = 1; i <= m; ++i)
		cin >> y[i] >> b[i] >> c[i];
	int u = 1;
	ll cntus = 0;
	ll ans = -2000000000000000000;
	for (int i = 1; i <= n; ++i) {
		cntus += a[i];
		while (u < m & y[u] < x[i]) u += 1;
		ll virc = 0;
		ll cntkup = 0;
		mys.clear();
		for (int j = 1; j < u; ++j) {
			virc += b[j] * c[j];
			mys.insert(make_pair(c[j], b[j]));
			cntkup += b[j];
		}
		ll mindb = -1;
		if (mys.size() > 0)mindb = mys.begin()->second;
		for (int j = u; j <= m; ++j) {
			ll dop = p*max(y[j], x[i]);
			pair<ll, ll> a;
			if (mys.size() > 0 && mindb > 0) {
				a = *mys.begin();
				mys.erase(a);
				a.second = mindb;
				mys.insert(a);
			}
			a = make_pair(c[j], b[j]);
			cntkup += b[j];
			virc += b[j] * c[j];
			mys.insert(a);
			if (cntkup >= cntus) {
				while (cntkup > cntus) {
					a = *mys.begin();
					mys.erase(a);
					if (cntkup - cntus >= a.second) {
						virc -= a.second*a.first;
						cntkup -= a.second;
						mindb = -1;
					}
					else {
						mindb = a.second;
						virc -= (cntkup - cntus)*a.first;
						a.second -= cntkup - cntus;
						cntkup = cntus;
						mys.insert(a);
					}
				}
				ans = max(ans, virc - dop);
			}

		}
	}
	cout << ans;
	return 0;
}