#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

const int maxn = (int) 5e5 + 100;

int n, m;
long long p;
pair <int, long long> ust[maxn];

struct point {
	int y;
	long long b, c;

	point(): y(0), b(0), c(0) {
	}

	point(int y, long long b, long long c) : y(y), b(b), c(c) {
	}
};

point base[maxn];
point help[maxn];

long long summ_ust[maxn];

bool comp(point a, point b) {
	return a.c > b.c;
}

long long fish_before(long long summ, int nm) {
	long long res = 0;

	for (int i = 0; i < nm; i++) {
		if (summ >= base[i].b) {
			res += base[i].b * base[i].c;
			summ -= base[i].b;
		}
		else {
			res += summ * base[i].c;
			summ = 0;
		}
	}

	return res;
}

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

	scanf("%d %d %lld", &n, &m, &p);

	for (int i = 0; i < n; i++) {
		int x;
		long long a;
		scanf("%d %lld", &x, &a);

		ust[i] = make_pair(x, a);
	}

	for (int i = 0; i < m; i++) {
		int y;
		long long b, c;
		scanf("%d %lld %lld", &y, &b, &c);

		base[i] = point(y, b, c);
	}

	summ_ust[0] = ust[0].second;

	for (int i = 1; i < n; i++) {
		summ_ust[i] = summ_ust[i - 1] + ust[i].second;
	}

	if (p == 0) {
		long long summ_fish = summ_ust[n - 1];

		sort(base, base + n, comp);

		long long res = 0;

		for (int i = 0; i < m; i++) {
			if (summ_fish >= base[i].b) {
				res += base[i].b * base[i].c;
				summ_fish -= base[i].b;
			}
			else {
				res += summ_fish * base[i].c;
				summ_fish = 0;
			}
		}

		cout << res;
		return 0;
	}

	if (ust[0].first > base[n - 1].y) {
		long long res = 0;
		for (int i = 0; i < n; i++) {
			long long now_res = 0 - ust[i].first * p;
			now_res += fish_before(summ_ust[i], m);
			res = max(res, now_res);
		}

		cout << res << endl;
		return 0;
	}

	if (ust[n - 1].first < base[0].y) {
		long long res = 0;
		long long summ_fish = summ_ust[n - 1];

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < i; j++) {
				help[j] = base[j];
			}

			sort(base, base + i, comp);

			res = max(res, fish_before(summ_fish, i) - p * base[i - 1].y);
		}

		cout << res;
		return 0;
	}

	return 0;
}
/*
3 2 0
1 5
2 3
4 5
2 2 10
3 6 5
*/

/*
2 1 100
6 5
100 4
5 100 2000
*/

/*
3 3 10 1 1
10 100
20 10
2 1000 1
11 50 50
17 50 2
*/