#include <random>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#pragma comment(linker, "/STACK:5120000000")
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 nmax = 500000;
const int mmax = 500000;
const int maxc = 1000003;

lint stq[maxc * 2 + 1] = {};
lint stm[maxc * 2 + 1] = {};

lint stget(int id, int sl, int sr, lint q) {
	if (q == 0)
		return 0;

	if (q == stq[id])
		return stm[id];

	lint ans = 0;
	if (sr - sl == 1) {
		return min(q, stq[id]) * sl;
	}

	int sm = (sl + sr) / 2;
	if (stq[sl * 2 + 1] <= q)
		return stget(sl * 2 + 1, sm, sr, q);
	else {
		return stm[sl * 2 + 1] + 
				stget(id * 2, sl, sm, q - stq[sl * 2 + 1]);
	}
}

void add(int id, int sl, int sr, int to, lint q) {
	int sm = (sl + sr) / 2;
	if (sl > to || sr <= to)
		return;

	stq[id] += q;
	stm[id] += q * to;
	if (sl + 1 < sr) {
		if (to < sm)
			add(id * 2, sl, sm, to, q);
		else add(id * 2 + 1, sm, sr, to, q);
	}
}

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[nmax], y[mmax];
	lint a[nmax], b[mmax], c[mmax];
	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[mmax + nmax];	// 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[mmax + 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;
	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;
			add(1, 0, maxc, c[id], b[id]);
		}
		else {	// add fish
			int id = -(pa.second + 1);
			fish += a[id];
		}

		maxans = max(maxans, stget(1, 0, maxc, fish));
	}

	cout << maxans;
	return 0;
}