#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
struct point
{
	long long x, type, fish, price, num;
};
bool comp(point a, point b)
{
	return a.x < b.x;
}
bool comp2(point a, point b)
{
	return a.price > b.price;
}
vector<pair<int, int> > dp;
int dpsize;
int bin_search(int x)
{
	int l, r, m;
	l = 0;
	r = dpsize;
	while (l < r - 1)
	{
		m = (l + 2) / 2;
		if (dp[m].first > x) r = m - 1;
		else l = m;
	}
	if (dp[r].first <= x) return r;
	else return l;
}
int main()
{
	ifstream in;
	ofstream out;
	in.open("fisher.in");
	out.open("fisher.out");
	long long n, m, i, p, ans = 0, totfish = 0, price = 0, newa;
	in >> n >> m >> p;
	vector<point> a(n + m);
	vector<point> mark(m), f(n);
	for (i = 0; i < n; i++)
	{
		in >> a[i].x >> a[i].fish;
		a[i].type = 1; //fish
		totfish += a[i].fish;
		f[i].fish = a[i].fish;
		f[i].x = a[i].x;
	}
	for (i = n; i < n + m; i++)
	{
		in >> a[i].x >> a[i].num >> a[i].price;
		a[i].type = 2; //sell
		mark[i - n].num = a[i].num;
		mark[i - n].price = a[i].price;
		mark[i - n].x = a[i].x;
	}
	sort(a.begin(), a.end(), comp);
	if (p == 0)
	{
		sort(mark.begin(), mark.end(), comp2);
		i = 0;
		while (totfish > 0 && i < m)
		{
			if (totfish > mark[i].num)
			{
				totfish -= mark[i].num;
				ans += mark[i].num * mark[i].price;
			}
			else
			{
				ans += totfish * mark[i].price;
				totfish = 0;
			}
			i++;
		}
	}
	else
	{
		sort(mark.begin(), mark.end(), comp2);
		sort(f.begin(), f.end(), comp);
		dp.push_back(make_pair(0, 0));
		dpsize = 0;
		for (i = 1; i <= m; i++)
		{
			dp.push_back(make_pair(dp[i - 1].first + mark[i - 1].num, dp[i - 1].second + mark[i - 1].price * mark[i - 1].num));
			dpsize++;
		}
		for (i = 0; i < n; i++)
		{
			if (i == 0) totfish = f[i].fish;
			else totfish += f[i].fish;
			if (i == 0) price = f[i].x * p;
			else price += (f[i].x - f[i - 1].x) * p;
			newa = dp[bin_search(totfish)].second + (totfish - dp[bin_search(totfish)].first) * mark[bin_search(totfish)].price;
			newa -= price;
			if (ans < newa) ans = newa;
		}
	}
	out << ans;
}