#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#include<set>
#include<cassert>
#include<vector>
using namespace std;
const int MAXN = 500 * 1000 + 7;
struct Event
{
	int pos;
	int type;
	int id;
	Event() {}
	Event(int _pos, int _type, int _id) // 1 for x, 2 for y
	{
		pos = _pos;
		type = _type;
		id = _id;
	}
};
bool operator<(Event x, Event y)
{
	return x.pos < y.pos;
}
int x[MAXN], a[MAXN], y[MAXN], b[MAXN], c[MAXN];
vector<Event>e;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p;
	scanf("%d %d %d", &n, &m, &p);
	assert(n <= 10000);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d %d", &x[i], &a[i]);
		e.push_back(Event(x[i], 1, i));
	}
	for (int i = 1; i <= m; i++)
	{
		scanf("%d %d %d", &y[i], &b[i], &c[i]);
		e.push_back(Event(y[i], 2, i));
	}
	vector<pair<int, int> >haveShops;
	long long curFish = 0;
	long long ans = 0;
	sort(e.begin(), e.end());
	for (int i = 0; i < (int)e.size(); i++)
	{
		if (e[i].type == 1)
		{
			curFish += a[e[i].id];
		}
		else
		{
			haveShops.push_back(make_pair(c[e[i].id], b[e[i].id]));
			sort(haveShops.rbegin(), haveShops.rend());
		}
		long long tmp = curFish;
		long long curans = -1LL * p*e[i].pos;
		for (int j = 0; j < (int)haveShops.size(); j++)
		{
			if (haveShops[j].second <= tmp)
			{
				curans += 1LL * haveShops[j].first*haveShops[j].second;
				tmp -= haveShops[j].second;
			}
			else
			{
				curans += 1LL * haveShops[j].first*tmp;
				break;
			}
		}
		ans = max(ans, curans);
	}
	printf("%lld\n", ans);
}