#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <functional>
#include <map>
#include <queue>

#define ll long long
#define ld long double
#define mp make_pair
#define TASKNAME "fisher"

using namespace std;

const ll inf = 1e9;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

struct poll {
	ll x, v, c;
	ll type;
	poll() : x(0), v(0), c(0), type(0) { }
	poll(ll x, ll v, ll type) : x(x), v(v), c(0), type(type) { }
	bool operator<(const poll p) const {
		return x < p.x;
	}
};

void solve() {
	ll n, m, p;
	cin >> n >> m >> p;
	vector<poll> a(n + m);
	for (ll i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].v;
		a[i].type = 0;
	}
	for (ll i = 0; i < m; i++) {
		cin >> a[n + i].x >> a[n + i].v >> a[n + i].c;
		a[n + i].type = 1;
	}
	sort(a.begin(), a.end());
	ll sz = a.size();
	ll curs = 0;
	set<pair<ll, ll>, greater<pair<ll, ll>>> t;
	ll ans = 0;
	for (ll i = 0; i < sz; i++) {
		ll curp = a[i].x * p;
		if (a[i].type == 0)
			curs += a[i].v;
		else t.insert(mp(a[i].c, a[i].v));
		ll s = curs;
		ll vv = 0;
		for (auto it = t.begin(); it != t.end(); it++) {
			pair<ll, ll> pc = *it;
			ll curv = min(s, pc.second);
			vv += curv * pc.first;
			s -= curv;
			if (s == 0)
				break;
		}
		ll curans = vv - curp;
		ans = max(ans, curans);
	}
	cout << ans;
}

int main() {
#ifdef __DEBUG__
	freopen("input.txt", "r", stdin);
	clock_t start = clock();
#else
	freopen(TASKNAME".in", "r", stdin);
	freopen(TASKNAME".out", "w", stdout);
#endif 

	solve();

#ifdef __DEBUG__
	cerr << "\nTime: " << (ld)(clock() - start) / (ld)CLOCKS_PER_SEC << endl;
#endif
}