#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <bitset>


using namespace std;

int solve();

#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fornn(i, q, n) for (int i = q; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair

typedef long long ll;

#define TASK "fisher"

int main() {
#ifdef KAZAN
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#else
	freopen(TASK".in", "r", stdin), freopen(TASK".out", "w", stdout);
#endif
	solve();
}

const int dd = 5e5 + 7;

ll x[dd], a[dd];
ll y[dd], b[dd], c[dd];

struct ev {
	ll x, tp, ind;
	bool operator < (ev b) const {
		return x < b.x;
	}
};

int solve() {
	ll n, m, p;
	scanf("%lld %lld %lld", &n, &m, &p);

	vector<ev> T(n + m);

	forn(i, n) {
		scanf("%lld %lld", &x[i], &a[i]);
		T[i].x = x[i];
		T[i].tp = 0;
		T[i].ind = i;
	}

	forn(i, m) {
		scanf("%lld %lld %lld", &y[i], &b[i], &c[i]);
		T[i + n].x = y[i];
		T[i + n].tp = 1;
		T[i + n].ind = i;
	}

	sort(all(T));

	ll ans = 0;
	ll cur = 0;

	set<pair<ll, ll> > S;

	for (auto t : T) {
		if (t.tp == 0) {
			cur += a[t.ind];
		}
		else {
			S.insert(mp(c[t.ind], b[t.ind]));
		}

		if (S.size() == 0)
			continue;

		auto it = S.end();
		it--;

		ll cc = 0;
		ll res = 0;

		for (;; it--) {
			if (cc + it->second <= cur) {
				res += 1ll * it->first * it->second;
				cc += it->second;
			}
			else {
				res += 1ll * it->first * (cur - cc);
				break;
			}

			if (it == S.begin())
				break;
		}

		res -= 1ll * t.x * p;
		ans = max(ans, res);
	}

	cout << ans;

	return 0;
}