#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;



class fenvick {
public:
	inline static ll f(ll x) {
		return x & (x - 1);
	}



	inline static ll g(ll x) {
		return 2 * x - f(x);
	}


	int *fen = new int[1000005];
	ll size = 1000005;


	ll sum(ll r) {
		ll ans = 0;
		while (r > 0) {
			ans += fen[r];
			r = f(r);
		}
		return ans;
	}


	void add(ll pos, ll val) {
		while (pos < size) {
			fen[pos] += val;
			pos = g(pos);
		}
	}



	ll sum(ll l, ll r) {
		if (l == 1)
			return sum(r);
		else
			return sum(r) - sum(l - 1);
	}


	inline bool help(ll x, ll t) {
		if (sum(x, size - 1) <= t)
			return true;
		return false;
	}


	bool help(ll x, ll t, ll r) {
		if (sum(x, r) >= t)
			return true;
		return false;
	}


	ll find(ll t) {
		ll l = 1, r = size - 1;
		while (r - l > 1) {
			ll m = (l + r) / 2;
			if (help(m, t))
				r = m;
			else
				l = m;
		}
		if (help(r, t))
			l = r;
		return l;
	}


	ll find(ll t, ll q) {
		ll l = 1, r = q;
		while (r - l > 1) {
			ll m = (l + r) / 2;
			if (help(m, t, q))
				l = m;
			else
				r = m;
		}
		if (help(r, t, q))
			l = r;
		return l;
	}

};


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;
	fenvick cnt, money;

	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 cur = 0;
	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_shop) {
			cnt.add(shop[j].second.first, shop[j].second.second);
			money.add(shop[j].second.first, shop[j].second.second * shop[j].second.first);
			++j;
		}
		else {
			cur += fish[i].second;
			++i;
		}

		ll tmp = cur;
		ll profit = 0;
		if (cnt.sum(cnt.size - 1) <= tmp)
			profit = money.sum(cnt.size - 1);
		else {
			int r = cnt.find(tmp);
			profit += money.sum(r, money.size - 1);
			tmp -= cnt.sum(r, cnt.size - 1);
			if (tmp > 0) {
				int l = cnt.find(1, r - 1);
				profit += l * tmp;
			}
		}
		profit -= dist * p;
		max_profit = max(profit, max_profit);
	}
	cout << max_profit << '\n';
}