#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 = 1e9;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

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

void solve() {
	int n, m, p;
	cin >> n >> m >> p;
	vector<point> a(n + m);
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].v;
		a[i].type = 0;
	}
	for (int 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());
	int sz = a.size();
	int curs = 0;
	vector<pair<int, int>> t;
	int ans = 0;
	for (int i = 0; i < sz; i++) {
		int curp = a[i].x * p;
		if (a[i].type == 0)
			curs += a[i].v;
		else t.push_back(mp(a[i].c, a[i].v));
		sort(t.begin(), t.end(), greater<pair<int, int>>());
		int s = curs;
		int vv = 0;
		for (int j = 0; j < t.size(); j++) {
			int curv = min(s, t[j].second);
			vv += curv * t[j].first;
			s -= curv;
			if (s == 0)
				break;
		}
		int 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
}