#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int mn = 1000010;
const int sq = 1000;
typedef pair <long long, long long> pll;
long long n, m, p, ans, sum;
pll v[mn / sq][3 * sq];
pll reb[mn];
long long k[mn / sq], sumsq[mn / sq], cntsq[mn / sq];
pair <long long, pll> e[mn];//event
pll x[mn];
pair <long long, pll> y[mn];

void push(pll x) {
	int i1 = 0, i2 = 0;
	while (i1 < sq && v[i1][i2].first <= x.first) {
		i1++;
	}
	if (i1 != 0) {
		i1--;
	}
	sumsq[i1] += x.first * x.second;
	cntsq[i1] += x.second;
	while (i2 < k[i1] && v[i1][i2].first < x.first) {
		i2++;
	}
	if (v[i1][i2].first == x.first) {
		v[i1][i2].second += x.second;
	} else {
		for (int i = k[i1]; i > i2; i--) {
			v[i1][i] = v[i1][i - 1];
		}
		v[i1][i2] = x;
		k[i1]++;
	}
}

void rebuild() {
	long long i1 = 0;
	for (int i = 0; i < sq; i++) {
		for (int j = 0; j < k[i]; j++) {
			reb[i1] = v[i][j];
			i1++;
		}
	}
	long long i2 = 0;
	for (int i = 0; i < sq; i++) {
		for (int j = 0; j < (i1 + i) / sq; j++) {
			v[i][j] = reb[i2];
			i2++;
		}
	}
}

long long ask() {
	long long q = sum, i1 = 0, ans2 = 0;
	while (i1 < sq && q > cntsq[i1]) {
		q -= cntsq[i1];
		ans2 -= sumsq[i1];
		i1++;
	}
	if (i1 != sq) {
		long long i2 = 0;
		while (i2 < k[i1] && q > v[i1][i2].second) {
			q -= v[i1][i2].second;
			ans2 -= v[i1][i2].first * v[i1][i2].second;
			i2++;
		}
		if (q > 0) {
			ans2 -= v[i1][i2].first * q;
		}
	}
	return ans2;
}

int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	for (int i = 0; i < n; i++) {
		long long q1, q2;
		scanf("%I64d%I64d", &q1, &q2);
		//cin >> q1 >> q2;
		x[i].first = q1;
		x[i].second = q2;
		e[i].first = q1;
		e[i].second.first = 0;
		e[i].second.second = i;
	}
	for (int i = 0; i < m; i++) {
		long long q1, q2, q3;
		scanf("%I64d%I64d%I64d", &q1, &q2, &q3);
		//cin >> q1 >> q2 >> q3;
		y[i].first = q1;
		y[i].second.first = -q3;
		y[i].second.second = q2;
		e[i + n].first = q1;
		e[i + n].second.first = 1;
		e[i + n].second.second = i;
	}
	ans = 0;
	sum = 0;
	if (p == 0) {
		for (int i = 0; i < n; i++) {
			sum += x[i].second;
		}
		for (int i = 0; i < m; i++) {
			x[i] = y[i].second;
		}
		sort(x, x + m);
		for (int i = 0; i < m; i++) {
			if (sum > x[i].second) {
				ans = ans - x[i].first * x[i].second;
				sum -= x[i].second;
			} else {
				ans = ans - x[i].first * sum;
				sum = 0;
				break;
			}
		}
		cout << ans;
		return 0;
	}
	n += m;
	sort(e, e + n);
	long long ans2 = 0;
	for (int i = 0; i < n; i++) {
		if (e[i].second.first == 0) {
			sum += x[e[i].second.second].second;
		} else {
			pll w = y[e[i].second.second].second;
			push(w);
		}
		ans2 = -p * e[i].first + ask();
		if (ans < ans2) {
			ans = ans2;
		}
		if ((i + 1) % sq == 0) {
			rebuild();
		}
	}
	cout << ans;
	return 0;
}