#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int lim = 500000;
/*const int segs = 625;
const int divv = lim / segs;*/

ll min(ll a, ll b) {
	return (a < b ? a : b);
}

ll max(ll a, ll b) {
	return (a > b ? a : b);
}

struct Fish {
	ll x;
	ll a;
	Fish() {}
	Fish(ll x, ll a) : x(x), a(a) {}
};

struct Shop {
	ll x;
	ll a;
	ll c;
	int rank;
	Shop() {}
	Shop(ll x, ll a, ll c) : x(x), a(a), c(c) {}
};

Fish arf[lim];
Shop ars[lim];
int sorted[lim];

/*struct Dec {
	ll acur, ccur;
	ll a, c;
	Dec() : acur(0), ccur(0) {}
};

Dec decc[segs];*/

/*struct Suff {
	ll a, c;
	Suff() {}
	Suff(ll a, ll c): a(a), c(c) {}
	Suff(Shop const &s) : a(s.a), c(s.a * s.c) {}
	Suff operator + (Shop const &s) const {
		return Suff(a + s.a, c + s.a * s.c);
	}
};
Suff suff[lim];*/

bool comp(int const &a, int const &b) {
	return ars[a].c < ars[b].c;
}

int f(int x) {
	return x & (-x);
}

struct Tree {
	int limit = lim;
	ll tree[lim];
	Tree() {}
	ll get(int x) {
		ll res = 0;
		for (; x < limit; x += f(x + 1))
			res += tree[x];
		return res;
	}
	void add(int x, ll val) {
		for (; x != -1; x -= f(x + 1))
			tree[x] += val;
	}
};

Tree suffa;
Tree suffc;

int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p, i, j, x, a, c;
	scanf("%d %d %d", &n, &m, &p);
	for (i = 0; i < n; ++i) {
		scanf("%d %d", &x, &a);
		arf[i] = Fish(x, a);
	}
	for (i = 0; i < m; ++i) {
		scanf("%d %d %d", &x, &a, &c);
		ars[i] = Shop(x, a, c);
		sorted[i] = i;
	}
	sort(sorted, sorted + m, comp);
	for (i = 0; i < m; ++i)
		ars[sorted[i]].rank = i;

	ll res = 0, total = 0;
	if (!p) {
		for (i = 0; i < n; ++i)
			total += arf[i].a;
		for (i = m - 1; i >= 0; --i) {
			res += ars[sorted[i]].c * min(total, ars[sorted[i]].a);
			total -= min(total, ars[sorted[i]].a);
		}
		printf("%lld", res);
		return 0;
	}
	if (ars[m - 1].x < arf[0].x) {
		j = m - 1;
		for (i = 0; i < n; ++i) {
			total -= p * (arf[i].x - (i ? arf[i - 1].x : 0));
			for (; j >= 0; --j) {
				if (arf[i].a >= ars[sorted[j]].a) {
					total += ars[sorted[j]].a * ars[sorted[j]].c;
					arf[i].a -= ars[sorted[j]].a;
					ars[sorted[j]].a = 0;
				}
				else {
					total += arf[i].a * ars[sorted[j]].c;
					ars[sorted[j]].a -= arf[i].a;
					arf[i].a = 0;
				}
				if (!arf[i].a)
					break;
			}
			res = max(res, total);
		}
		printf("%lld", res);
		return 0;
	}
	/*if (arf[n - 1].x < ars[0].x) {
		ll emone = 0;
		for (i = 0; i < n; ++i)
			total += arf[i].a;
		for (i = 0; i < m; ++i) {
			if (total) {
				if (total >= ars[i].a) {
					emone += ars[i].a * ars[i].c;
					total -= ars[i].a;
					ars[i].a = 0;
				}
				else {
					emone += total * ars[i].c;
					ars[i].a -= total;
					total = 0;
				}
			}
			if (ars[i].a) {

			}
			res = max(res, emone - p * ars[i].x);
		}
		printf("%lld", res);
		return 0;
	}*/
	/*for (i = 0; i < m; ++i) {
		decc[i / divv].a += ars[i].a;
		decc[i / divv].c += ars[i].c * ars[i].a;
	}
	ll emone = 0;
	i = 0;
	j = 0;
	while (i < n && j < m) {
		bool isi;
		if (i == n)
			isi = false;
		if (j == m)
			isi = true;
		if (i < n && j < m)
			isi = arf[i].x < ars[j].x;
		if (isi) {
			total += arf[i].a;
			for (j = segs; )
			res = max(res, emone - (p * arf[i].x));
			++i;
		}
		else {
			res = max(res, emone - (p * ars[j].x));
			++j;
		}
	}*/
	/*suff[m - 1] = Suff(ars[m - 1]);
	for (i = m - 2; i >= 0; --i)
		suff[i] = suff[i + 1] + ars[i];*/
	suffa.limit = m;
	suffc.limit = m;
	ll emone = 0;
	int l, r, mid;
	i = 0;
	j = 0;
	while (i < n || j < m) {
		bool isi;
		if (i == n)
			isi = false;
		if (j == m)
			isi = true;
		if (i < n && j < m)
			isi = arf[i].x < ars[j].x;
		if (isi) {
			total += arf[i].a;
			++i;
		}
		else {
			suffa.add(ars[j].rank, ars[j].a);
			suffc.add(ars[j].rank, ars[j].a * ars[j].c);
			++j;
		}
		if (total >= suffa.get(0))
			emone = suffc.get(0);
		else {
			for (l = 0, r = m; l + 1 < r;) {
				mid = (l + r + 1) / 2;
				(total >= suffa.get(mid) ? r : l) = mid;
			}
			emone = suffc.get(r) + ars[r - 1].c * (total - suffa.get(r));
		}
		res = max(res, emone - (p * (isi ? arf[i - 1].x : ars[j - 1].x)));
	}
	printf("%lld", res);
	return 0;
}