#include <random>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#pragma comment(linker, "/STACK:512000000")
using namespace std;

//#define int long long
#define lint long long
#define vint vector<vector<long long>>

lint& gget(pair<int, int> &i, vint& v) {
	return v[i.first][i.second];
}
pair<int, int>& gget(pair<int, int> &i, vector<vector<pair<int, int>>> & v) {
	return v[i.first][i.second];
}

//const int n = 500000;
//const int m = 500000;

lint ans(lint fish, vector<pair<lint, lint>>& cb) {
	lint r = 0;
	for (int i = 0; i < cb.size() && fish > 0; i++) {
		lint q = min(fish, cb[i].second);
		fish -= q;
		r += cb[i].first * q;
	}
	return r;
}

int32_t main() {
	ifstream cin("fisher.in");
	ofstream cout("fisher.out");
	ios::sync_with_stdio(false);

	int n, m;
	lint p;
	cin >> n >> m >> p;
	int x[n], y[m];
	lint a[n], b[m], c[m];
	for (int i = 0; i < n; i++)
		cin >> x[i] >> a[i];
	for (int i = 0; i < m; i++)
		cin >> y[i] >> b[i] >> c[i];

	pair<int, int> line[m + n];	// x, ind
	for (int i = 0; i < n; i++) {
		line[i] = { x[i], -i - 1 };
	}
	for (int i = 0; i < m; i++) {
		line[n + i] = { y[i], i };
	}
	sort(line, line + n + m);

	vector< pair<lint, lint> > costs[m + 1]; // costs[i] - {c max, b}, ..., {c min, b} - first i sellers
	priority_queue<pair<lint, lint>> q;
	for (int i = 0; i <= m; i++) {
		auto qc = q;
		while (qc.size() != 0) {
			costs[i].push_back(qc.top());
			qc.pop();
		}
		//reverse(costs[i].begin(), costs[i].end());

		if (i < m)
			q.push({ c[i], b[i] });
	}

	lint maxans = 0;
	lint fish = 0;
	int si = 0;
	for (int i = 0; i < n + m; i++) {
		auto pa = line[i];
		int x = pa.first;
		if (pa.second >= 0) {	// add sell
			int id = pa.second;
			si++;
		}
		else {	// add fish
			int id = -(pa.second + 1);
			fish += a[id];
		}

		maxans = max(maxans, ans(fish, costs[si]) - p * x);
	}

	cout << maxans;
	return 0;
}