#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;

const int MAXN = (int)5e5 + 47;

int n, m, p;

struct Fish
{
	int x, a;
};

struct Shop
{
	int x, b, c;
};

vector < Fish > ff;
vector < Shop > ss;

void input()
{
	scanf("%d %d %d", &n, &m, &p);
	ff.resize(n);
	ss.resize(m);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &ff[i].x, &ff[i].a);
	for (int i = 0; i < m; i++)
		scanf("%d %d %d", &ss[i].x, &ss[i].b, &ss[i].c);
}

bool cmp(const Shop &a, const Shop &b)
{
	return a.c > b.c || (a.c == b.c && a.b > b.b);
}

void out(ll ans)
{
	cout << ans;
	exit(0);
}

void task1()
{
	ll sum = 0;
	for (int i = 0; i < n; i++)
		sum += ff[i].a;
	sort(ss.begin(), ss.end(), cmp);
	ll ans = 0, kk, cnt = 0;
	for (int i = 0; i < (int)ss.size(); i++)
	{
		kk = min(sum, (ll)ss[i].b);
		sum -= kk;
		ans += kk * ss[i].c;
	}
	out(ans);
}

void task2()
{
	ll ans = 0;
	ll sum = 0, cnt = 0, kk = 0;
	multiset < pair < int, int > > st;
	multiset < pair < int, int > >::reverse_iterator it;
	for (int i = 0; i < m; i++)
		st.insert({ ss[i].c, ss[i].b });
	ll c, b;
	for (int i = 0; i < n; i++)
	{
		while (!st.empty() && ff[i].a > 0)
		{
			if (kk == 0)
			{
				it = st.rbegin();
				c = it->first;
				b = it->second;
				kk = b;
				st.erase(st.find(*it));
			}
			cnt = min(kk, (ll)ff[i].a);
			sum += cnt * c;
			kk -= cnt;
			ff[i].a -= cnt;
		}
		ans = max(ans, sum - (ll)ff[i].x * p);
	}
	out(ans);
}

void task3()
{
	ll ans = 0;
	ll suma = 0;
	ll sum = 0, cnt = 0, kk = 0;
	for (int i = 0; i < n; i++)
		suma += ff[i].a;
	ll c, b;
	ll sumb = 0;
	multiset < pair < int, int > > st;
	multiset < pair < int, int > >::reverse_iterator it;
	for (int i = 0; i < m; i++)
	{
		if (sumb < suma)
		{
			st.insert({ ss[i].c, ss[i].b });
			kk = min((ll)ss[i].b, suma - sumb);
			sumb += ss[i].b;
		}
		else
		{
			it = st.rbegin();
			c = it->first;
			b = it->second;
			if (sumb - b >= suma)
			{
				st.erase(st.find(*it));
			}
			else
			{
				if (c < )
			}
		}
	}
	out(ans);
}


bool isTask2()
{
	return ss[m - 1].x < ff[0].x;
}

bool isTask3()
{
	return ff[n - 1].x < ss[0].x;
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	input();
	// task1
	if (p == 0)
		task1();
	if (isTask2())
		task2();
	if (isTask3())
	return 0;
}