#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

#define rep(i, n) for (decltype(n) i = 0; i < n; i++)
#define dep(i, n) for (decltype(n) i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (decltype(b) i = a; i <= b; i++)
#define FORD(i, a, b) for (decltype(a) i = a; i >= b; i--)
#define len(a) (int)a.size()
#define all(a) a.begin(), a.end()
typedef long long int64;
using namespace std;

const int maxn = 5e5 + 10;

int64 x[maxn], a[maxn], y[maxn], b[maxn], c[maxn], cf[maxn];

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m;
	int64 p;
	cin >> n >> m >> p;
	rep(i, n)
	{
		cin >> x[i] >> a[i];
	}
	rep(i, m)
	{
		cin >> y[i] >> b[i] >> c[i];
	}
	if (p == 0)
	{
		int64 fish = 0;
		rep(i, n)
			fish += a[i];
		vector<pair<int64, int64> > q;
		rep(i, m)
			q.push_back({ c[i], b[i] });
		sort(q.rbegin(), q.rend());
		int64 ans = 0;
		for (auto x : q)
		{
			ans += min(fish, x.second) * x.first;
			fish = max(0ll, fish - x.second);
		}
		cout << ans << endl;
		return 0;
	}
	if (y[m - 1] < x[0])
	{
		int64 fish = 0;
		vector<pair<int64, int64> > q;
		rep(i, m)
			q.push_back({ c[i], b[i] });
		sort(q.rbegin(), q.rend());
		int ptr = 0;
		int64 cur = 0, ans = 0;
		cur -= p * x[0];
		rep(i, n)
		{
			fish += a[i];
			while (ptr < len(q) && fish)
			{
				cur += min(fish, q[ptr].second) * q[ptr].first;
				if (q[ptr].second <= fish)
				{
					fish -= q[ptr].second;
					ptr++;
				}
				else
				{
					q[ptr].second -= fish;
					fish = 0ll;
				}
			}
			if (i)
				cur -= p * (x[i] - x[i - 1]);
			ans = max(ans, cur);
		}
		cout << ans << endl;
		return 0;
	}
	else
	{
		vector<int64> crd;
		rep(i, n)
			crd.push_back(x[i]);
		rep(i, m)
			crd.push_back(y[i]);
		sort(all(crd));
		crd.resize(unique(all(crd)) - crd.begin());
		int64 ans = 0;
		rep(t, len(crd))
		{
			int64 fish = 0;
			int64 cur = -p * crd[t];
			rep(i, n)
			{
				if (x[i] > crd[t])
					continue;
				fish += x[i];
			}
			vector<pair<int64, int64> > q;
			rep(i, m)
			{
				if (y[i] > crd[t])
					continue;
				q.push_back({ c[i], b[i] });
			}
			sort(q.rbegin(), q.rend());
			for (auto x : q)
			{
				cur += min(fish, x.second) * x.first;
				fish = max(0ll, fish - x.second);
			}
			ans = max(ans, cur);
		}
		cout << ans << endl;
		return 0;
	}
	return 0;
}