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

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

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

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

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &p);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &x[i], &a[i]);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d%d", &y, &b, &c);
		o[i].y = y;
		o[i].b = b;
		o[i].c = c;
	}
	qsort(o, m, 3 * sizeof(int), 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];
	}
	printf("%d", ans);
	return 0;
}