//#include "stdafx.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;
long long i, n, k, z, g, kol, j,p;
struct tt
{
	long long y;
	long long b;
	long long c;
};
long long a[500001],x[500001], m2[500001], a1[500001], x1[500001];
tt m[500001],m1[500001];
vector<long long> m4;
bool cmp1(const tt & a, const tt & b)
{
	return (a.c < b.c || ((a.c==b.c) && (a.b<b.b)));
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	scanf("%I64d%I64d%I64d", &n, &k, &p);
	for (int i = 1; i <= n; i++)
		scanf("%I64d%I64d", &x[i], &a[i]);
	for (int i = 1; i <= k; i++)
		scanf("%I64d%I64d%I64d", &m[i].y, &m[i].b, &m[i].c);
	long long res = 0;
	if (p == 0)
	{
		long long a1=0,b1=0;
		for (int i = 1; i <= n; i++)
			a1 += a[i];
		sort(m+1,m+k+1,cmp1);
		for (int i = k; i >= 1; i--)
		{
			res += min(a1, m[i].b)*m[i].c;
			a1 = max((long long)0, a1 - m[i].b);
		}
	}
	else
		if (m[k].y<x[1])
		{
			sort(m + 1, m + k + 1, cmp1);
			long long teksum = 0;
			int res1 = k;
			for (int i = 1; i <= n; i++)
			{
				long long b1 = a[i];
				while (res1 > 0 && m[res1].b>0 && b1>0)
				{
					teksum += m[res1].c*min(b1, m[res1].b);
					long long c1 = b1;
					b1 -= min(b1, m[res1].b);
					m[res1].b -= min(c1, m[res1].b);
					if (m[res1].b == 0)
						res1--;
				}
				res = max(res, -x[i] * p + teksum);
			}
		}
		else
		{
			m4.clear();
			m4.push_back(0);
			for (int i = 1; i <= n; i++)
				m4.push_back(x[i]);
			for (int i = 1; i <= k; i++)
				m4.push_back(m[i].y);
			sort(m4.begin(), m4.end());
			for (int ee = 1; ee < m4.size; ee++)
			{
				int kol1 = 0, kol2 = 0;
				for (int z = 1; z <= n;z++)
					if (x[z] <= m4[ee])
					{
						kol1++;
						x1[kol1] = x[z];
						a1[kol1] = a[z];
					}
				for (int z = 1; z <= k;z++)
					if (m[z].y < m4[ee])
					{
						kol2++;
						m1[kol2] = m[z];
					}
				sort(m1 + 1, m1 + kol2 + 1, cmp1);
				long long teksum = 0;
				int res1 = kol2;
				for (int i = 1; i <= kol1; i++)
				{
					long long b1 = a1[i];
					while (res1 > 0 && m1[res1].b>0 && b1>0)
					{
						teksum += m1[res1].c*min(b1, m1[res1].b);
						long long c1 = b1;
						b1 -= min(b1, m1[res1].b);
						m[res1].b -= min(c1, m1[res1].b);
						if (m1[res1].b == 0)
							res1--;
					}
					res = max(res, -x1[i] * p + teksum);
				}
		}
	printf("%I64d", res);
	return 0;
}