#include <stdio.h>
#include <stdlib.h>

struct base {
	__int64 y, b, c;
};

const int e = 500000;
int n, m;
__int64 p, x[e], a[e], y, b, c, ulov, profit, ans = 0;
base o[e];

int comp(const void * a, const void * b)
{
	base x = *(base*)a;
	base y = *(base*)b;
	return x.c - y.c;
}

__int64 min(__int64 a, __int64 b)
{
	return a < b ? a : b;
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	scanf("%d%d%I64d", &n, &m, &p);
	for (int i = 0; i < n; i++)
		scanf("%I64d%I64d", &x[i], &a[i]);
	for (int i = 0; i < m; i++)
	{
		scanf("%I64d%I64d%I64d", &y, &b, &c);
		o[i].y = y;
		o[i].b = b;
		o[i].c = c;
	}
	qsort(o, m, 3 * sizeof(__int64), comp);
	ulov = 0;
	for (int i = 0; i < n; i++)
	{
		profit = 0;
		ulov += a[i];
		int tmp = ulov;
		int j = m - 1;
		while (tmp > 0 && j >= 0)
		{
			if (o[j].y <= x[i])
			{
				profit += min(tmp, o[j].b) * o[j].c;
				tmp -= o[j].b;
			}
			j--;
		}
		if (profit - p * x[i] > ans)
			ans = profit - p * x[i];
	}

	for (int i = 0; i < m; i++)
	{
		profit = 0;
		int tmp = 0;
		for (int j = 0; j < n; j++)
			if (x[j] <= o[i].y)
				tmp += a[j];
		int j = m - 1;
		while (tmp > 0 && j >= 0)
		{
			if (o[j].y <= o[i].y)
			{
				profit += min(tmp, o[j].b) * o[j].c;
				tmp -= o[j].b;
			}
			j--;
		}
		if (profit - p * o[i].y > ans)
			ans = profit - p * o[i].y;
	}
	printf("%I64d", ans);
	return 0;
}