#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

#pragma warning (disable:4996)

#define ll long long int
#define mlp make_pair
#define x1 first
#define y1 second

ll n, mm, d[2000007], st[2000007], p, x[500007], y[500007], a[500007], b[500007], c[500007],poz[500007],lst;
vector<vector<ll> > v,pt;
vector <ll> ok(5);

void add(int u, int l, int r, int l1, int r1, ll x, ll y) {
	int m = (l + r) / 2;
	if (l == l1&&r == r1) {
		st[u] += x;
		d[u] += y;
		return;
	}
	st[2 * u] += st[u];
	st[2 * u + 1] += st[u];
	st[u] = 0;
	d[2 * u] += d[u];
	d[2 * u + 1] += d[u];
	d[u] = 0;
	if (r1 <= m) {
		add(2 * u, l, m, l1, r1, x, y);
		return;
	}
	if (l1 > m) {
		add(2 * u + 1, m + 1, r, l1, r1, x, y);
		return;
	}
	add(2 * u, l, m, l1, m, x, y);
	add(2 * u + 1, m + 1, r, m + 1, r1, x, y);
	return;
}

ll ask(int u, int l, int r, int x) {
	int m = (l + r) / 2;
	if (x == -1)return 0;
	if (l == r) {
		return st[u];
	}
	st[2 * u] += st[u];
	st[2 * u + 1] += st[u];
	st[u] = 0;
	d[2 * u] += d[u];
	d[2 * u + 1] += d[u];
	d[u] = 0;
	if (x <= m)return ask(2 * u, l, m, x);
	return ask(2 * u + 1, m + 1, r, x);
}
ll ask1(int u, int l, int r, int x) {
	int m = (l + r) / 2;
	if (x == -1)return 0;
	if (l == r) {
		return d[u];
	}
	st[2 * u] += st[u];
	st[2 * u + 1] += st[u];
	st[u] = 0;
	d[2 * u] += d[u];
	d[2 * u + 1] += d[u];
	d[u] = 0;
	if (x <= m)return ask1(2 * u, l, m, x);
	return ask1(2 * u + 1, m + 1, r, x);
}

ll find(ll s) {
	int l, r, m;
	l = 0;
	r = mm;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (ask(1, 0, mm-1, m) < s) {
			l = m;
		}
		else {
			r = m;
		}
	}
	ll ss;
	if (r != mm) {
		ss = ask(1, 0, mm - 1, r);
		if (ss > ask(1, 0, mm - 1, l) && ss >= s)l = r;
	}
	return l;
}

void sol() {
	ll i, j, ans = 0;
	cin >> n >> mm >> p;
	for (i = 0; i < n; i++) {
		scanf("%I64d%I64d", &x[i], &a[i]);
		ok[0] = x[i];
		ok[1] = 1;
		ok[2] = a[i];
		ok[3] = i;
		v.push_back(ok);
	}
	for (i = 0; i < mm; i++) {
		scanf("%I64d%I64d%I64d", &y[i], &b[i], &c[i]);
		ok[0] = y[i];
		ok[1] = 0;
		ok[2] = b[i];
		ok[3] = c[i]*b[i];
		ok[4] = i;
		v.push_back(ok);
		ok[0] = c[i];
		ok[1] = i;
		pt.push_back(ok);
	}
	sort(v.begin(), v.end());
	sort(pt.rbegin(), pt.rend());
	for (i = 0; i < mm; i++) {
		poz[pt[i][1]] = i;
	}
	ll s = 0;
	for (i = 0; i < v.size(); i++) {
		if (v[i][1] == 0) {
			add(1, 0, mm - 1, poz[v[i][4]], mm - 1, v[i][2], v[i][3]);
		}
		else {
			s += v[i][2];
		}
		ll k = min(s, ask(1, 0, mm - 1, mm - 1));
		if (k != 0) {
			int ind = find(k);
			ll ss = -p*v[i][0] + ask1(1, 0, mm - 1, ind - 1) + min(s - ask(1, 0, mm - 1, ind - 1),b[pt[ind][1]])*c[pt[ind][1]];
			ans = max(ans, ss);
		}
	}
	cout << ans;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#endif

	sol();
	return 0;
}