#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstdlib>
#define ll long long
using namespace std;

const int MAXN = 1e5 + 111;

struct CC
{
	int y, b, c;
	CC() {}
	CC(int y, int b, int c) : y(y), b(b), c(c) {}
};

struct XX
{
	int x, a;
	XX() {}
	XX(int x, int a) : x(x), a(a) {}
};

ll pref[MAXN];

int n, m, p;

XX x[MAXN];

CC c[MAXN];

bool operator <(CC a, CC b)
{
	return a.c < b.c;
}

void solve1()
{
	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++)
		sum += x[i].a;
	sort(c + 0, c + m);
	for (int i = m - 1; i >= 0; i--)
	{
		if (sum >= c[i].b)
		{
			ans += (ll)c[i].b * c[i].c;
			sum -= c[i].b;
		}
		else
		{
			ans += sum * c[i].c;
			sum = 0;
		}
	}
	cout << ans;
	exit(0);
}

void solve2()
{
	sort(c + 0, c + m);
	int id = m - 1;
	int cur = 0;
	ll ans = 0;
	ll cc = 0;
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cc -= (ll)(x[i].x - cur) * p;
		cur = x[i].x;
		sum += x[i].a;
		if (id == -1)
			break;
		if (sum >= c[id].b)
		{
			cc += (ll)c[id].b * c[id].c;
			sum -= c[id].b;
			c[id].b = 0;
			id--;
		}
		else
		{
			cc += sum * c[id].c;
			c[id].b -= sum;
			sum = 0;
		}
		ans = max(ans, cc);
	}
	cout << ans;
	exit(0);
}

/*void solve3()
{
	ll sum = 0;
	for (int i = 0; i < n; i++)
	sum += x[i].a;
	ll ans = 0;
	ll cc = 0;
	int cur = 0;
	for (int i = 0; i < m; i++)
	{
		cc -= (ll)(c[i].y - cur) * p;
		cur = c[i].y;

	}
}*/

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].x, &x[i].a);
		if (i)
			pref[i] = pref[i - 1] + x[i].a;
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d %d", &c[i].y, &c[i].b, &c[i].c);
	}
	if (p == 0)
		solve1();
	if (c[m - 1].y < x[0].x)
		solve2();
	/*if (x[n - 1].x < c[0].y)
		solve3();*/
	return 0;
}