#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <set>
#include <functional>
#include <map>
#include <queue>

#define ll long long
#define ld long double
#define mp make_pair
#define TASKNAME "fisher"

using namespace std;

const ll inf = 1e18;
const ll infLL = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

struct sqrtd {
	struct block {
		ll size;
		ll minv;
		ll vsum;
		ll qans;
		vector<pair<ll, ll>> c;
		block() : size(0), vsum(0), qans(0), minv(infLL) { }
		block(vector<pair<ll, ll>>::iterator s, vector<pair<ll, ll>>::iterator e) {
			c = vector<pair<ll, ll>>(s, e);
			size = c.size();
			minv = infLL;
			for (ll i = 0; i < c.size(); i++) {
				minv = min(minv, c[i].first);
				vsum += c[i].second;
				qans += c[i].second * c[i].first;
			}
		}
		void insert(pair<ll, ll> a) {
			ll p = 0;
			for (p = 0; p < c.size() && c[p].first > a.first; p++);
			c.insert(c.begin() + p, a);
			size++;
			minv = min(minv, a.first);
			vsum += a.second;
			qans += a.second * a.first;
		}
		ll get(ll s) {
			ll ans = 0;
			for (ll i = 0; i < size; i++) {
				pair<ll, ll> pc = c[i];
				ll curv = min(s, pc.second);
				ans += curv * pc.first;
				s -= curv;
				if (s == 0)
					break;
			}
			return ans;
		}
		pair<block, block> split() {
			ll tm = size / 2;
			return mp(block(c.begin(), c.begin() + tm), block(c.begin() + tm, c.end()));
		}
	};
	ll blocksize;
	ll size;
	vector<block> c;
	sqrtd(ll bsize) : blocksize(bsize) {
		size = 1;
		c.push_back(block());
	}
	void insert(pair<ll, ll> a) {
		ll p = 0;
		for (p = 0; p < size && c[p].minv > a.first; p++);
		if (p == size)
			p--;
		c[p].insert(a);
		if (c[p].size == 2 * blocksize) {
			pair<block, block> pp = c[p].split();
			c[p] = pp.second;
			c.insert(c.begin() + p, pp.first);
			size++;
		}
	}
	ll get(ll s) {
		ll ans = 0;
		ll p = 0;
		for (p = 0; p < size && c[p].vsum <= s; p++) {
			s -= c[p].vsum;
			ans += c[p].qans;
		}
		if (p != size)
			ans += c[p].get(s);
		return ans;
	}
};

struct poll {
	ll x, v, c;
	ll type;
	poll() : x(0), v(0), c(0), type(0) { }
	poll(ll x, ll v, ll type) : x(x), v(v), c(0), type(type) { }
	bool operator<(const poll p) const {
		return x < p.x;
	}
};

void solve() {
	ll n, m, p;
	cin >> n >> m >> p;
	vector<poll> a(n + m);
	for (ll i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].v;
		a[i].type = 0;
	}
	for (ll i = 0; i < m; i++) {
		cin >> a[n + i].x >> a[n + i].v >> a[n + i].c;
		a[n + i].type = 1;
	}
	sort(a.begin(), a.end());
	ll sz = a.size();
	sqrtd t(ceil(sqrt(sz)));
	ll curs = 0;
	ll ans = 0;
	for (ll i = 0; i < sz; i++) {
		ll curp = a[i].x * p;
		if (a[i].type == 0)
			curs += a[i].v;
		else t.insert(mp(a[i].c, a[i].v));
		ll vv = t.get(curs);
		ll curans = vv - curp;
		ans = max(ans, curans);
	}
	cout << ans;
}

int main() {
#ifdef __DEBUG__
	freopen("input.txt", "r", stdin);
	clock_t start = clock();
#else
	freopen(TASKNAME".in", "r", stdin);
	freopen(TASKNAME".out", "w", stdout);
#endif 

	solve();

#ifdef __DEBUG__
	cerr << "\nTime: " << (ld)(clock() - start) / (ld)CLOCKS_PER_SEC << endl;
#endif
}