#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define MAXN 700007

typedef long long slong;


struct base {
	slong x;
	char type;
	slong a, b, c;
	int id;

	base(int i, int pos, char t, int aa, int bb, int cc) {
		id = i;
		x = pos;
		type = t;
		a = aa;
		b = bb;
		c = cc;
	}
	base() {
		id = -1;
		x = 0;
		type = 0;
		a = 0;
		b = 0;
		c = 0;
	}

	const bool operator <(base r) {
		if (x != r.x)
			return x < r.x;
		if (type != r.type)
			return type < r.type;
		return id < r.id;
	}
};

bool cmp1(base u, base v) {
	return v.c < u.c;
};

int n, m;
slong p, ans = 0;
base all[MAXN];
int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);

	scanf("%d%d%d", &n, &m, &p);
	for (int i=0; i<n; i++) {
		int x, a;
		scanf("%d%d", &x, &a);
		all[i] = base(i, x, 0, a, 0, 0);
	}
	for (int i=0; i<m; i++) {
		int x, b, c;
		scanf("%d%d%d", &x, &b, &c);
		all[i+n] = base(i, x, 1, 0, b, c);
	}

	sort(all, all+n+m);
	slong curFish = 0;
	vector<base> cons;
	for (int i=0; i<n+m; i++) {
		curFish += all[i].a;
		if (all[i].c > 0) {
			vector<base>::iterator it = cons.begin();
			bool f = false;
			while (it < cons.end() && !f) {
				if ((*it).c <= all[i].c)
					f = true;
				it++;
			}
			if (it > cons.begin() && f)
				it--;
			cons.insert(it, all[i]);
		}

		slong nowFish = curFish, nowAns = -all[i].x * p;
		for (unsigned int j=0; j<cons.size(); j++) {
			base cn = cons[j];
			slong k = min(nowFish, cn.b);
			nowFish -= k;
			nowAns += k * cn.c;
		}
		ans = max(ans, nowAns);
	}

	printf("%lld\n", ans);
}


