#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

const long long  MAX = 5 * 1e5 + 13, INF = 1e10;

long long  n, m, p;

struct baza {
	long long  y, b, c;
};

struct lov {
	long long  x, a;
};

baza baz[MAX];

lov lo[MAX];

bool cmp(baza a, baza b) {
	return a.c <= b.c;
}

int main() {
	//freopen("tests.txt", "r", stdin);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);

	cin >> n >> m >> p;
	long long s = 0;
	for (long long i = 1; i <= n; i++) {
		cin >> lo[i].x >> lo[i].a;
		s += lo[i].a;
	}
	for (long long i = 1; i <= m; i++) {
		cin >> baz[i].y >> baz[i].b >> baz[i].c;
	}

	if (p == 0) {
		long long ans = 0;
		sort(baz + 1, baz + m + 1, cmp);
		for (long long i = m; i >= 1; i--) {
			if (baz[i].b <= s) {
				ans += baz[i].b * baz[i].c;
				s -= baz[i].b;
			}
			else {
				ans += s * baz[i].c;
				s = 0;
			}
		}
		cout << ans;
		return 0;
	}

	if (baz[m].y < lo[1].x) {
		sort(baz + 1, baz + m + 1, cmp);
		long long ans = -INF, cnt = 0;
		long long ulov = 0, uk = m, prib = 0;;

		for (long long i = 1; i <= n; i++) {
			ulov += lo[i].a;
			cnt -= p * (lo[i].x - lo[i - 1].x);
			long long t = lo[i].a;
			while (t > 0 && uk >= 1) {
				if (t <= baz[uk].b) {
					cnt += t * baz[uk].c;
					baz[uk].b -= t;
					t = 0;
				}
				else {
					t -= baz[uk].b;
					cnt += baz[uk].c * baz[uk].b;
					baz[uk].b = 0;
					uk--;
				}
			}
			ans = max(ans, cnt);
		}
		cout << ans;
		return 0;
	}

	if (baz[m].y > lo[1].x) {
		map<long long, long long> mp;

		long long ans = -INF, cnt = 0, kol = 0;
		for (long long i = 1; i <= m; i++) {
			cnt -= p * (baz[i].y - baz[i - 1].y);
			kol += baz[i].b;
			cnt += baz[i].b * baz[i].c;
			mp[baz[i].c] += baz[i].b;
			if (kol <= s) {
				ans = max(cnt, ans);
				continue;
			}
			long long t = kol - s;
			for (auto it = mp.begin(); it != mp.end(); ++it) {
				if (t <= it->second) {
					mp[it->first] -= t;
					cnt -= t * it->first;
					t = 0;
					break;
				}
				else {
					cnt -= it->first * it->second;
					t -= it->second;
					mp[it->first] = 0;
				}
			}
			ans = max(cnt, ans);
		}
		cout << ans;
		return 0;
	}
	return 0;
}