#include <stdio.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iterator>
#include <utility>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

const int MAXN = 500000;

struct event {
	int pos, mx, cost;
};
vector<event> v;

bool cmp(const event& first, const event& second) {
	return first.pos < second.pos;
}

long long t[4 * 2 * MAXN + 1];

int main() {
	ios_base::sync_with_stdio(false);
	ifstream cin("fisher.in");
	ofstream cout("fisher.out");

	int n, m, p;
	cin >> n >> m >> p;
	for (int i = 0; i < n; i++) {
		int x, a;
		cin >> x >> a;
		v.push_back({ x, a });
	}
	for (int i = 0; i < m; i++) {
		int y, b, c;
		cin >> y >> b >> c;
		v.push_back({ y, b, c });
	}
	sort(v.begin(), v.end(), cmp);
	long long ans = 0, cur = 0, sum = 0, fish = 0;
	multiset<pair<int, int> > was;
	for (int i = 0; i < (int)v.size(); i++) {
		if (v[i].cost) {
			int mn = min((long long)v[i].mx, fish);
			sum += 1LL * mn * v[i].cost;
			fish -= mn;
			v[i].mx -= mn;
			for (int j = 1; j < v[i].cost && v[i].mx; j++) {
				int lost = min((long long)v[i].mx, t[j]);
				v[i].mx -= lost;
				t[j] -= lost;
				sum -= 1LL * j * lost;
				sum += 1LL * lost * v[i].cost;
			}
			if (v[i].mx)
				was.insert({ v[i].cost, v[i].mx });
		}
		else {
			while (!was.empty()) {
				if (!v[i].mx)
					break;
				auto it = was.end();
				it--;
				int cost = it->first;
				int cnt = it->second;
				int tmp = it->second;
				was.erase(it);
				cnt = min(cnt, v[i].mx);
				t[cost] += cnt;
				v[i].mx -= cnt;
				sum += 1LL * cnt * cost;
				if (tmp - cnt)
					was.insert({ cost, tmp - cnt });
			}
			fish += v[i].mx;
		}
		ans = max(ans, sum - 1LL * v[i].pos * p);
	}
	cout << ans << endl;
	return 0;
}