#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <fstream>
ifstream cin("fisher.in");
ofstream cout("fisher.out");
#endif

int n, m, p;

int x[50000], a[500000];

pair < int ,  int > l[50000];

int main() {
	cin >> n >> m >> p;
	if (p == 0) {
		long long f = 0;
		for (int i = 0; i < n; i++) {
			cin >> x[i] >> a[i];
			f += a[i];
		}
		for (int i = 0; i < m; i++) {
			int y, b, c;
			cin >> y >> b >> c;
			l[i] = { c , b };
		}
		sort(l, l + m);
		int ans = 0;
		for (int i = m - 1; i >= 0; i--) {
			if (f > 0) {
				if (f >= l[i].second) {
					f -= l[i].second;
					ans += l[i].second * l[i].first;
				}
				else {
					ans += f * l[i].first;
					f = 0;
				}
			}
		}
		cout << ans;
	}
}