#include <iostream>
#include <cstdlib>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

typedef long long int ll;

const int SIZE = 500000;

int a[SIZE];
int x[SIZE], y[SIZE];
pair<ll, ll> b[SIZE];
ll cost[SIZE];

int main()
{
#ifndef _CONSOLE
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
#endif

	int n, m, p;

	cin >> n >> m >> p;

	for (int i = 0; i < n; i++)
		cin >> x[i] >> a[i];

	for (int i = 0; i < m; i++)
		cin >> y[i] >> b[i].second >> b[i].first;

	if (p == 0) {
		ll sum = 0;
		for (int i = 0; i < n; i++)
			sum += a[i];

		sort(b, b + m, greater<pair<ll, ll>>());

		int i = 0;
		ll cost = 0;
		while (i < m && sum > 0) {
			ll t = min(sum, b[i].second);

			sum -= t;
			cost += t * b[i].first;
			i++;
		}

		cout << cost << endl;
	}
	else if (x[n - 1] < y[0]) {
		ll sum = 0;
		for (int i = 0; i < n; i++)
			sum += a[i];

		ll max = 0;
		
		cost[0] = min(sum, b[0].second) * b[0].first;
		sum -= min(sum, b[0].second);
		if (cost[0] - p * y[0] > max)
			max = cost[0] - p * y[0];

		for (int i = 1; i < m; i++) {
			cost[i] = cost[i - 1] + min(sum, b[i].second) * b[i].first;
			sum -= min(sum, b[i].second);
			if (cost[i] - p * y[i] > max)
				max = cost[i] - p * y[i];
		}

		cout << max << endl;
	}
}