#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<int, pll> a, pair<int, 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;
	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)));
	}
	if (p == 0)
	{
		ll ans = 0;
		ll weig = 0;
		forn(i, n)
			weig += a[i].y;
		sort(all(b), cmpb);
		/*forn(i, m)
			cout << b[i].y.y << " ";*/
		forn(i, m)
		{
			if (b[i].y.x < weig)
			{
				weig -= b[i].y.x;
				ans += b[i].y.x * b[i].y.y;
			}
			else
			{
				ans += weig * b[i].y.y;
				weig = 0;
				break;
			}
		}
		cout << ans;
		return 0;
	}
	if (b[m - 1].x < a[0].x)
	{
		ll ans = 0;
		ll weig = 0;
		sort(all(b), cmpb);
		ll s = 0, w = 0;
		forn(i, m)
		{
			w += b[i].y.x;
			s += b[i].y.x * b[i].y.y;
			prefb.pb(mk(w, s));
		}
		forn(i, n)
		{
			weig += a[i].y;
			prefa.pb(weig);
		}
		forn(i, n)
		{
			ll tekans = -p * a[i].x;
			ll pl = 0;
			weig = prefa[i];
			if (weig > prefb[m - 1].x)
				pl = prefb[m - 1].y;
			else
			{
				int pos = lb(weig);
				ll pr = 0;
				if (pos == -1)
				{
					pl = weig * b[0].y.y;
				}
				else
				{
					pr = (prefb[pos + 1].y - prefb[pos].y) / (prefb[pos + 1].x - prefb[pos].x);
					pl = prefb[pos].y + (weig - prefb[pos].x) * pr;
				}
			}
			ans = max(ans, tekans + pl);
		}
		cout << ans;
	}


	return 0;
}