#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <memory.h>
#define mp make_pair
using namespace std;


typedef long long ll;

const int MAXN = 500010;
const int C = 1000 * 1000;
const int INF = 1000 * 1000 * 1000 + 2;
ll r1[4 * C];
ll r2[4 * C];

int lv;
ll rv;

pair <int, int> sob[2 * MAXN];
int sc = 0;
int a[2 * MAXN], b[2 * MAXN];


int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p;
	scanf("%d%d%d", &n, &m, &p);
	memset(r1, 0, sizeof(r1));
	memset(r2, 0, sizeof(r2));
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d%d", &x, a + i);
		sob[i] = mp(x, i);
	}
	for (int i = 0; i < m; i++)
	{
		int x;
		scanf("%d%d%d", &x, a + n + i, b + n + i);
		sob[n + i] = mp(x, n + i);
	}
	ll ans = 0;
	sort(sob, sob + n + m);
	ll fish = 0;
	for (int i = 0; i < n + m; i++)
	{
		int vv = sob[i].second;
		if (vv < n) fish += a[vv];
		else
		{
			ll mlt = (a[vv] * b[vv]);
			int v = 0, l = 0, r = C;
			while (l != r)
			{
				r1[v] += b[vv];
				r2[v] += mlt;
				int md = (l + r) / 2;
				if (b[vv] <= md) v = v * 2 + 1, r = md;
				else v = v * 2 + 2, l = md + 1;
			}
			r1[v] += a[vv];
			r2[v] += mlt;
		}	
		ll rs = 0;
		ll cf = fish;
		int v = 0, l = 0, r = C;
		while (l != r)
		{
			int md = (l + r) / 2;
			v = (v + 1) * 2;
			if (r1[v] > cf)
			{
			     l = md + 1;
			}
			else
			{
				cf -= r1[v];
				rs += r2[v--];
				r = md;
			}
		}
		rs += min(r1[v], cf) * l;
		ans = max(ans, rs - (ll)p * (ll)sob[i].first);
	}
	cout << ans << endl;
	return 0;
}