#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <string>

using namespace std;

#pragma warning(disable:4996)

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long ll;

struct FT {
	vector<ll> T;
	int s;

	FT() {
		s = 0;
	}

	FT(int n) {
		T.assign(n, 0);
		s = n;
	}

	int G(int a) {
		return a - (a&(a - 1));
	}

	ll ask(int p) {
		ll ans = 0;
		for (int i = p; i > 0; i -= G(i)) {
			ans += T[i];
		}
		return ans;
	}

	void add(int p, ll val) {
		for (int i = p; i < s; i += G(i)) {
			T[i] += val;
		}
	}
};

FT fish(1 << 20), gain(1 << 20);
ll fishSum = 0;

void addBase(ll b, ll c) {
	fish.add((1 << 20) - c, b);
	gain.add((1 << 20) - c, b*c);
}

ll ask() {
	int l = 0, r = (1 << 20);
	while (r - l > 1) {
		int c = (l + r) >> 1;
		if (fish.ask(c) > fishSum) {
			r = c;
		}
		else {
			l = c;
		}
	}
	ll ans = gain.ask(l);
	ans += ((1 << 20) - r) * (fishSum - fish.ask(l));
	return ans;
}

struct ev {
	int p, b, c;
	ev() {
		p = b = c = 0;
	}
	ev(int P, int B) {
		p = P;
		b = B;
		c = -1;
	}
	ev(int P, int B, int C) {
		p = P;
		b = B;
		c = C;
	}
};

bool operator<(ev a, ev b) {
	return a.p < b.p;
}

vector<ev> e;

void solve() {
	int n, m, a, b, c;
	ll p;
	scanf("%d%d%lld", &n, &m, &p);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &a, &b);
		e.emplace_back(a, b);
	}
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d", &a, &b, &c);
		e.emplace_back(a, b, c);
	}
	sort(e.begin(), e.end());
	ll ans = 0;
	for (int i = 0; i < n + m; ++i) {
		if (e[i].c == -1) {
			fishSum += e[i].b;
		}
		else {
			addBase(e[i].b, e[i].c);
		}
		ans = max(ans, ask() - e[i].p*p);
	}
	printf("%lld", ans);
}

int main() {
#pragma comment(linker,"/STACK:536870912")
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	freopen("fisher.in", "rt", stdin);
	freopen("fisher.out", "wt", stdout);
#endif
	solve();
	return 0;
}