#pragma comment(linker, "/stack:25600000")

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct pt
{
	long long a, x, c, b;
};

bool lessx(pt x, pt y)
{
	return x.x < y.x;
}

bool lessc(pt x, pt y)
{
	return x.c > y.c;
}

int main()
{
	long long n, m, p;
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	vector<pt> mas;
	for (int i = 0; i < n; i++)
	{
		long long x, y;
		cin >> x >> y;
		pt A;
		A.a = y;
		A.x = x;
		A.c = 0;
		A.b = 0;
		mas.push_back(A);
	}
	for (int i = 0; i < m; i++)
	{
		long long x, y, z;
		cin >> x >> y >> z;
		pt A;
		A.a = 0;
		A.x = x;
		A.c = z;
		A.b = y;
		mas.push_back(A);
	}
	sort(mas.begin(), mas.end(), lessx);
	if (p == 0)
	{
		long long amax = 0;
		for (int i = 0; i < mas.size(); i++)
			amax += mas[i].a;
		sort(mas.begin(), mas.end(), lessc);
		long long ans = 0;
		for (int i = 0; i < mas.size(); i++)
		{
			if (amax > mas[i].b)
				ans += mas[i].c * mas[i].b, amax -= mas[i].b;
			else
				ans += mas[i].c * amax, amax = 0;
		}
		cout << ans;
		return 0;
	}
	if (mas[0].a == 0)
	{
		vector<pair<long long, long long> > cury;
		int i = 0;
		while (mas[i].a == 0)
		{
			cury.push_back(make_pair(mas[i].c, mas[i].b));
			i++;
		}
		sort(cury.begin(), cury.end());
		reverse(cury.begin(), cury.end());
		long long l = 0, curans = 0, ans = -1e17, nowa = 0;
		for (int j = i; j < mas.size(); j++)
		{
			nowa += mas[i].a;
			while (l < mas.size() && nowa >= mas[l].b)
			{
				nowa -= mas[l].b;
				curans += mas[l].b * mas[l].c;
				mas[l].b = 0;
				l++;
			}
			if (l != mas.size())
			{
				curans += nowa * mas[l].c;
				mas[l].b -= nowa;
				nowa = 0;
			}
			ans = max(ans, curans - mas[j].x * p);
		}
		cout << ans;
		return 0;
	}

	return 0;
}