#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>

using namespace std;

#define pii pair<int, int>

const int N = 5e5;

int a[N];
int x[N];

int b[N];
int y[N];
int c[N];
map <int, int> mp;

vector <pair <int, pii> > v;

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m;
	long long p;
	scanf("%d %d %I64d", &n, &m, &p);
	for (int i = 0; i < n; ++i)
		scanf("%d %d", &x[i], &a[i]),
		v.push_back({ x[i], {-1, a[i]} });
	for (int i = 0; i < m; ++i)
		scanf("%d %d %d", &y[i], &b[i], &c[i]),
		v.push_back({ y[i],{ i, -1 } });
	sort(v.begin(), v.end());
	long long ans = 0;
	int amount = 0;
	long long water = 0;
	for (int i = 0; i < v.size(); ++i)
	{
		if (v[i].second.first == -1)
			amount += v[i].second.second;
		else
		{
			int id = v[i].second.first;
			mp[-c[id]] += b[id];
		}
		int have = 0;
		long long cur = 0;
		for (auto x : mp)
		{
			cur += x.first * min(amount - have, x.second);
			if (have == amount)
				break;
		}
		ans = max(ans, -p * v[i].first - cur);
	}
	cout << ans << "\n";
	return 0;
}