#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <memory.h>

using namespace std;

#define int long long
#define sz(a) (int)(a.size())

struct fish
{
	int x, cnt;
};

struct shop
{
	int x, cnt, cost;
};

int n, m, p;
const int MAXN = 5 * 1e4 + 100;
fish a[MAXN];
shop b[MAXN];

signed main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].x >> a[i].cnt;
	}
	for (int i = 1; i <= m; ++i)
	{
		cin >> b[i].x >> b[i].cnt >> b[i].cost;
	}
	if (p == 0)
	{
		long long sum = 0;
		for (int i = 1; i <= n; ++i)
		{
			sum += a[i].cnt;
		}
		auto cmp = [](shop a, shop b) { return a.cost > b.cost; };
		sort(b + 1, b + m + 1, cmp);
		long long ans = 0;
		for (int i = 1; i <= m; ++i)
		{
			int t = min(sum, 1LL * b[i].cnt);
			sum -= t;
			ans += t * b[i].cost;
		}
		cout << ans;
		return 0;
	}
	else if (b[m].x <= a[1].x)
	{
		int top = 0;
		int sum = 0;
		auto cmp = [](shop a, shop b) { return a.cost > b.cost; };
		sort(b + 1, b + m + 1, cmp);
		int ans = 0;
		a[0].x = 0;
		int ptr = 1;
		int cur = 0;
		for (int i = 1; i <= n; ++i)
		{
			top += (a[i].x - a[i - 1].x) * p;
			sum += a[i].cnt;
			cur -= top;
			for (int j = ptr; j <= m; ++j)
			{
				int t = min(sum, b[i].cnt);
				sum -= t;
				b[i].cnt -= t;
				cur += t * b[i].cost;
				if (sum == 0)
				{
					ptr = j;
					break;
				}
			}
			ans = max(ans, cur);
		}
		cout << ans;
		return 0;
	}
	else
	{
		assert(0);
	}
	return 0;
}