#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
ifstream in("fisher.in");
ofstream out("fisher.out");

bool cmp(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
	return a.second.second > b.second.second;
}

int main()
{
	int n, m, p;
	in >> n >> m >> p;
	vector<pair<int, int>> a(n);
	vector<pair<int, pair<int, int>>> b(m);
	long long s = 0;
	for (int i = 0; i < n; ++i) {
		in >> a[i].first >> a[i].second;
		s += a[i].second;
	}
	for (int i = 0; i < m; ++i) {
		in >> b[i].first >> b[i].second.first >> b[i].second.second;
	}
	if (p == 0) {
		sort(b.begin(), b.end(), cmp);
		long long r = 0;
		for (int i = 0; i < b.size(); ++i) {
			if (s >= b[i].second.first) {
				s -= b[i].second.first;
				r += (long long)(b[i].second.first) * b[i].second.second;
			}
			else {
				r += (long long)(s)* b[i].second.second;
				s = 0;
				break;
			}
		}
		out << r;
	}
	else {
		int i = 0, j = 0;
		long long r = 0;
		long long sum = 0;
		while (j < m || i < n) {
			long long nr = 0;
			if (j == m || a[i].first <= b[j].first) {
				sum += a[i].second;
				nr -= (long long)p * (a[i].first);
				++i;
			}
			else {
				nr -= (long long)p * (b[j].first);
				++j;
			}
			vector<pair<int, pair<int, int>>> bn(b.begin(), b.begin() + j);
			sort(bn.begin(), bn.end(), cmp);
			long long sumc = sum;
			for (int i = 0; i < bn.size(); ++i) {
				if (sum >= bn[i].second.first) {
					sum -= bn[i].second.first;
					nr += (long long)(bn[i].second.first) * bn[i].second.second;
				}
				else {
					nr += (long long)(sum)* bn[i].second.second;
					sum = 0;
					break;
				}
			}
			sum = sumc;
			r = max(r, nr);
		}
		out << r;
	}
}