#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <set>
#include <map>

using namespace std;

#define int long long
int n, m, p;
int get_ans(int k, vector <pair <int, int> > v) {
	int ans = 0;
	sort(v.rbegin(), v.rend());
	for (int i = 0; i < v.size(); ++i) {
		if (k >= v[i].second) {
			ans += v[i].second * v[i].first;
			k -= v[i].second;
		}
		else {
			ans += k * v[i].first;
			k = 0;
		}
	}
	return ans;
}
void res() {
	int ss = 0;
	for (int i = 1; i <= n; ++i) {
		int a, b;
		cin >> a >> b;
		ss += b;
	}
	vector <pair <int, int> > v;
	for (int i = 1; i <= m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		v.push_back(make_pair(c, b));
	}
	cout << get_ans(ss, v) << endl;
	exit(0);
}
signed main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	
	
	cin >> n >> m >> p;
	if (p == 0) res();
}