#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define fi(a, b) for (li i = a; i <= b; ++i)
#define fj(a, b) for (li j = a; j <= b; ++j)
#define dfi(a, b) for (li i = a; i >= b; --i)
#define mp make_pair

typedef long long li;
typedef pair<li, li> pl;

const li MAXN = 5e5;

struct base {
	li x, b, c;
};

struct place {
	li x, a;
};

place pc[MAXN];
base b[MAXN];
li pre[MAXN];
set<pl> sr;

bool cmp(base b1, base b2) {
	if (b1.c > b2.c)
		return 1;
	else
		return 0;
}


int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	li n, m, p;

	cin >> n >> m >> p;

	fi(0, n - 1)
		cin >> pc[i].x >> pc[i].a;
	fi(0, m - 1)
		cin >> b[i].x >> b[i].b >> b[i].c;

	if (p == 0) {
		sort(b, b + m, cmp);
		li sum = 0, ans = 0;
		fi(0, n - 1)
			sum += pc[i].a;
		li i = 0;
		while (sum) {
			li q = min(b[i].b, sum);
			sum -= q;
			ans += q * b[i].c;
			++i;
			if (i >= m)
				break;
		}
		cout << ans;
	}
	else if (b[m - 1].x < pc[0].x) {
		li sum = 0, ans = 0;
		sort(b, b + m, cmp);
		li j = 0;
		li tr = 0, tc = 0;
		fi(0, n - 1) {
			li q = pc[i].a, t;
			if (i)
				t = pc[i].x - pc[i - 1].x;
			else
				t = pc[i].x;
			if (j >= m)
				break;
			tc += t * p;
			while (q) {
				if (q >= (b[j].b - sum)) {
					q -= b[j].b - sum;
					tr += b[j].c * (b[j].b - sum);
					sum = 0;
					++j;
				}
				else {
					sum += q;
					tr += q * b[j].c;
					q = 0;
				}  
				if (j >= m)
					break;
			}
			if (tr >= tc) {
				ans += tr - tc;
				tr = 0;
				tc = 0;
			}
		}
		cout << ans;
	}
	else if (pc[n - 1].x < b[0].x) {
		li sum = 0, ans = 0, cur = 0, ts = 0;
		li j = 0;
		li tr = 0, tc = 0;
		pre[0] = b[0].b;
		fi(1, m - 1)
			pre[i] = pre[i - 1] + b[i].b;
		fi(0, n - 1)
			sum += pc[i].a;
		fi(0, m - 1) {
			li w = min(b[i].b, sum - ts);
			sr.insert(mp(b[i].c, w));
			ts += w;
			cur += b[i].c * w;
			set<pl>::iterator itin = sr.begin(), it = sr.find(mp(b[i].c, w));
			li tc;
			if (i)
				tc = b[i].x - b[i - 1].x;
			else
				tc = b[i].x;
			cur -= tc * p;
			ans = max(ans, cur);
			if (b[i].b == w)
				continue;
			while (1) {
				if (it == sr.begin())
					break;
				li q = min(b[i].b - it->second, itin->second);
				pl bn = mp(itin->first, itin->second - q), bt = mp(it->first, it->second + q);
				if (bt.first == bn.first)
					break;
				cur += q * (bt.first - bn.first);
				sr.erase(itin);
				sr.erase(mp(b[i].c, 0));
				sr.insert(bt);
				if (bn.second == 0)
					break;
				else
					sr.insert(bn);
				itin = sr.begin();
				it = sr.find(bt);
				if (bt.second == b[i].b)
					break;
			}
			ans = max(ans, cur);
		}
		cout << ans;
	}

	return 0;
}