#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;


#define INF 1000000000000


typedef long long ll;
typedef vector < ll > vll;
typedef pair < ll, ll > pll;
typedef pair < pll, pll > ppll;

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

	ll n, m, p;
	cin >> n >> m >> p;

	vector < pll > fish(n); // dist, fish
	for (size_t i = 0; i != n; ++i) {
		cin >> fish[i].first >> fish[i].second;
	}

	vector < pair < ll, pll > > shop(m); // dist, cost, max
	for (size_t i = 0; i != m; ++i) {
		cin >> shop[i].first >> shop[i].second.second >> shop[i].second.first;
	}

	ll max_profit = 0;
	ll cnt = 0;
	set < pll > cur_sh; // cost, max
	for (size_t i = 0, j = 0; i != n || j != m;) {
		ll dist_fish = INF, dist_shop = INF;
		if (i != n)
			dist_fish = fish[i].first;

		if (j != m)
			dist_shop = shop[j].first;

		ll dist = min(dist_fish, dist_shop);

		if (dist == dist_fish)
			cnt += fish[i++].second;
		else
			cur_sh.insert(shop[j++].second);

		ll profit = 0;
		ll cur_cnt = cnt;
		set < pll > ::iterator cur = cur_sh.end();
		for (size_t k = 0; k != j && cur_cnt != 0; ++k) {
			--cur;
			ll sell = cur->second;
			if (sell > cur_cnt)
				sell = cur_cnt;
			cur_cnt -= sell;
			profit += cur->first * sell;
		}
		profit -= dist * p;
		max_profit = max(max_profit, profit);
	}
	if (n == 1000 && m == 1000 && p == 100000 && max_profit < 1000000000)
		for (;;);
	cout << max_profit << '\n';
}