#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<vector>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mk make_pair
#define ppb pop_back
#define pb push_back
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
#define forq(i, q, n) for(int i = 1; i < n; ++i)
#define all(a) a.begin(), a.end()
#define x first
#define y second

const int mod = 1e9 + 7;
const ll inf = 1e15 + 7;
const double eps = 1e-6;
const int MAXN = 1e5 + 7;

vector<pll> a;
vector<pair<ll, pll> > b;
ll n, m, p;

bool cmpb(pair<ll, pll> a, pair<ll, pll> b)
{
	return a.y.y > b.y.y || a.y.y == b.y.y && a.y.x > a.y.x;
}

vector<pll> prefb;
vector<ll> prefa;

int lb(ll z)
{
	int l = -1;
	int r = m;
	while (r - l > 1)
	{
		int mid = (r + l) / 2;
		if (prefb[mid].x > z)
			r = mid;
		else
			l = mid;
	}
	return l;
}

int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	set<pii> s;
	forn(i, n)
	{
		ll r, w;
		scanf("%lld%lld", &r, &w);
		a.pb(mk(r, w));
	}
	forn(i, m)
	{
		ll r, w, p;
		scanf("%lld%lld%lld", &r, &w, &p);
		b.pb(mk(r, mk(w, p)));
	}
	ll weig = 0;
	forn(i, n)
	{
		weig += a[i].y;
		prefa.pb(weig);
	}
	ll ans = 0;
	weig = 0;
	int uka = 0;
	int ukb = 0;
	while (uka <= n - 1 && ukb <= m - 1)
	{
		ll tekans = -p * max(a[uka].x, b[ukb].x);
		ll pl = 0;
		s.insert(mk(b[ukb].y.y, b[ukb].y.x));
		weig = prefa[uka];
		for (auto it = s.rbegin(); it != s.rend(); ++it)
		{
			if (weig > it->y)
			{
				weig -= it->y;
				pl += it->y * it->x;
			}
			else
			{
				pl += it->x * weig;
				break;
			}
		}

		ans = max(ans, tekans + pl);
		if (uka >= n - 1)
			ukb++;
		else
			if (ukb >= m - 1)
				uka++;
			else
				if (a[uka + 1].x < b[ukb + 1].x)
					uka++;
				else
					ukb++;
	}
	cout << ans;

	return 0;
}