#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <set>
#include <map>

using namespace std;

#define int long long
int n, m, p;
int get_ans(int k, vector <pair <int, int> > v) {
	int ans = 0;
	sort(v.rbegin(), v.rend());
	for (int i = 0; i < v.size(); ++i) {
		if (k >= v[i].second) {
			ans += v[i].second * v[i].first;
			k -= v[i].second;
		}
		else {
			ans += k * v[i].first;
			k = 0;
		}
	}
	return ans;
}
void res() {
	int ss = 0;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		ss += b;
	}
	vector <pair <int, int> > v;
	for (int i = 1; i <= m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		v.push_back(make_pair(c, b));
	}
	cout << get_ans(ss, v) << endl;
	exit(0);
}
void res2() {
	vector <pair <int, int> > xx;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		xx.push_back(make_pair(a, b));
	}
	multiset <pair <int, int> > v;
	for (int i = 1; i <= m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		v.insert(make_pair(c, b));
	}
	int ans = 0;
	int est = 0;
	for (int i = 0; i < n; ++i) {
		int hh = p * xx[i].first;
		while (v.size() && xx[i].second) {
			pair <int, int> cur = *v.rbegin();
			v.erase(--v.end());
			if (xx[i].second > cur.second) {
				est += cur.second * cur.first;
				xx[i].second -= cur.second;
				cur.second = 0;
			}
			else {
				est += xx[i].second * cur.first;
				cur.second -= xx[i].second;
				xx[i].second = 0;
			}
			if (cur.second) v.insert(cur);
		}
		ans = max(ans, est - hh);
	}
	cout << ans << endl;
	exit(0);
}
signed main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	
	
	cin >> n >> m >> p;
	if (p == 0) res();
	res2();
}