#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rall(a) (a).rbegin(), (a).rend()
#define all(a) (a).begin(), (a).end()

struct Event{
	int x, ab, c;
	bool type;
};

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);

	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);

	int n, m, p;
	cin >> n >> m >> p;

	if (n > 1e4 && p > 0) {
		vector<pair<int, int> > xs(n + 1, {0, 0});

		for (int i = 1; i <= n; i++) {
			cin >> xs[i].first >> xs[i].second;
		}

		sort(all(xs));

		multiset<pair<int, int> > buyers;

		for (int i = 0; i < m; i++) {
			int x, a, c;
			cin >> x >> a >> c;
			buyers.insert({-c, a});
		}

		ll nowFish = 0, nowAns = 0;
		ll ans = 0;

		for (int i = 1; i <= n; i++) {
			nowAns -= (ll)(xs[i].first - xs[i - 1].first) * (ll)p;
			nowFish += xs[i].second;

			while (!buyers.empty() && nowFish) {
				auto it = buyers.begin();
				nowAns += (ll)(-it->first) * (ll)min(nowFish, (ll)it->second);
				nowFish -= min(nowFish, (ll)it->second);
				if (it->second <= nowFish) {
					buyers.erase(buyers.begin());
				}
			}

			ans = max(ans, nowAns);
		}

		cout << ans << "\n";

		return 0;
	}

	vector<Event> events;

	for (int i = 0; i < n; i++) {
		int x, a;
		cin >> x >> a;

		events.push_back({x, a, 0, 0});
	}

	for (int i = 0; i < m; i++) {
		int x, a, c;
		cin >> x >> a >> c;

		events.push_back({x, a, c, 1});
	}

	ll nowFish = 0;
	multiset<pair<int, int> > buyers;

	ll ans = 0;

	sort(all(events), [] (Event a, Event b) { return a.x < b.x; });

	for (auto e : events) {
		if (e.type == 0) {
			nowFish += e.ab;
		} else {
			buyers.insert({-e.c, e.ab});
		}

		if (p > 0) {
			ll cNowFish = nowFish;
			ll nowAns = -((ll)e.x * (ll)p);

			for (auto it = buyers.begin(); it != buyers.end() && cNowFish; it++) {
				nowAns += (ll)(-it->first) * (ll)min(cNowFish, (ll)it->second);
				cNowFish -= min(cNowFish, (ll)it->second);
			}

			ans = max(ans, nowAns);
		}
	}

	if (p == 0) {
		ll cNowFish = nowFish;

		for (auto it = buyers.begin(); it != buyers.end() && cNowFish; it++) {
			ans += (ll)(-it->first) * (ll)min(cNowFish, (ll)it->second);
			cNowFish -= min(cNowFish, (ll)it->second);
		}
	}

	cout << ans << "\n";

	return 0;
}
