#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stdio.h>
#include <list>
#include <algorithm>
#pragma warning(disable: 4996)
typedef long long ll;
typedef long double ld;
using namespace std;

const ll SZ = 1e3 + 10;
const ll INF = 1e9;

vector<pair<ll, pair<bool, pair<ll, ll>>>> d;

struct treap {
	ll pr, lg, mean, gr, ladd, meanadd, lasts;
	treap *l, *r;
	treap() {}
	treap(ll llg, ll mmean, ll ggr, ll llasts) {
		pr = rand();
		lasts = llasts;
		lg = llg;
		gr = ggr;
		mean = mmean;
		ladd = meanadd = 0;
		l = r = NULL;
	}
};
treap *t = NULL;

void recalc(treap *t) {
	if (!t)
		return;
	t->lg += t->ladd;
	t->mean += t->meanadd;
	if (t->l) {
		t->l->ladd += t->ladd;
		t->l->meanadd += t->meanadd;
	}
	if (t->r) {
		t->r->ladd += t->ladd;
		t->r->meanadd += t->meanadd;
	}
	t->ladd = t->meanadd = 0;
}

treap* merge(treap *l, treap *r) {
	//recalc(l); recalc(r);
	if (!l)
		return r;
	if (!r)
		return l;
	if (l->pr > r->pr) {
		l->r = merge(l->r, r);
		//recalc(l);
		return l;
	}
	else {
		r->l = merge(l, r->l);
		//recalc(r);
		return r;
	}
}

pair<treap*, treap*> split_lg(treap *t, ll x) {
	recalc(t);
	if (!t)
		return{ NULL, NULL };
	if (t->lg > x) {
		auto e = split_lg(t->l, x);
		t->l = e.second;
		recalc(t);
		return{ e.first, t };
	}
	else {
		auto e = split_lg(t->r, x);
		t->r = e.first;
		recalc(t);
		return{ t, e.second };
	}
}

pair<treap*, treap*> split_gr(treap *t, ll x) {
	recalc(t);
	if (!t)
		return{ NULL, NULL };
	if (t->gr < x) {
		auto e = split_gr(t->l, x);
		t->l = e.second;
		recalc(t);
		return{ e.first, t };
	}
	else {
		auto e = split_gr(t->r, x);
		t->r = e.first;
		recalc(t);
		return{ t, e.second };
	}
}

treap* getright(treap *t) {
	recalc(t);
	if (t->r)
		return getright(t->r);
	return t;
}

void add(ll gr, ll la) {
	auto x = split_gr(t, gr);
	auto y = getright(x.first);
	auto z = new treap(y->lg + y->lasts, y->mean + (y->lasts * y->gr), gr, la);
	if (x.second) {
		x.second->meanadd += gr * la;
		x.second->ladd += la;
		//recalc(x.second);
	}
	t = merge(x.first, merge(z, x.second));
}

ll get(ll x) {
	auto a = split_lg(t, x);
	auto b = getright(a.first);
	ll ret = b->mean + b->gr * (x - b->lg);
	t = merge(a.first, a.second);
	return ret;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#endif
	srand(857'574'567);

	t = merge(new treap(0, 0, INF, 0), new treap(0, 0, 0, INF));

	ll n, m, p;
	cin >> n >> m >> p;
	for (ll i = 0; i < n; i++) {
		ll x, a;
		cin >> x >> a;
		d.push_back({ x,{ false,{ a, 0 } } });
	}
	for (ll i = 0; i < m; i++) {
		ll y, b, c;
		cin >> y >> b >> c;
		d.push_back({ y,{ true,{ b, c } } });
	}

	ll ans = 0, taken = 0;
	sort(d.begin(), d.end());
	for (auto i : d)
		if (!i.second.first) {
			taken += i.second.second.first;
			ans = max(ans, get(taken) - i.first * p);
		}
		else {
			add(i.second.second.second, i.second.second.first);
			ans = max(ans, get(taken) - i.first * p);
		}

		cout << ans;
		return 0;
}