#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <fstream>

using namespace std;

struct st {
	long long x, b, c;
	bool flag;
	st(){}
	st(long long X, long long B, long long C, bool Flag) {
		x = X;
		b = B;
		c = C;
		flag = Flag;
	}
};

bool cmp(st a, st b) {
	return a.x < b.x;
}

multiset < pair<long long, long long> > s;
long long maxy, ul, n, m, p;
vector <st> v;

int main() {
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ifstream cin("fisher.in");
	ofstream cout("fisher.out");
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> p;
	for (int i = 1; i <= n; i++) {
		long long x, a;
		cin >> x >> a;
		v.push_back(st(x, a, 0, 0));
	}
	for (int i = 1; i <= m; i++) {
		long long y, b, c;
		cin >> y >> b >> c;
		v.push_back(st(y, b, c, 1));
	}
	sort(v.begin(), v.end(), cmp);
	if (p == 0) {
		long long ull = 0, sum = 0;
		for (int i = 0; i < v.size(); i++) {
			if (v[i].flag == 0) {
				ul += v[i].b;
			}
			else {
				s.insert({ v[i].c, v[i].b });
			}
			ull = ul;
		}
		ull = ul;
		for (auto it = s.rbegin(); it != s.rend(); it++)
			if (ull >= it->second) {
				sum += it->second * it->first;
				ull -= it->second;
			}
			else {
				sum += ull * it->first;
				ull = 0;
			}
			maxy = max(sum, maxy);
	}
	/*for (int i = 0; i < v.size(); i++) {
		long long ull = 0, sum = 0;
		if (v[i].flag == 0) {
			ul += v[i].b;
		}
		else {
			s.insert({ v[i].c, v[i].b });
		}
		ull = ul;
		for (auto it = s.rbegin(); it != s.rend(); it++)
			if (ull >= it->second) {
				sum += it->second * it->first;
				ull -= it->second;
			}
			else {
				sum += ull * it->first;
				ull = 0;
			}
			maxy = max(sum - v[i].x * p, maxy);
	}*/
	cout << maxy;
	return 0;
}