#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
pair<int, int> x[500001];
pair<int, pair<int, int> > y[500001];
int p;
int main() {
freopen("fisher.in", "r", stdin);
freopen("fisher.out", "w", stdout);
	int n, m;
	cin >> n >> m >> p;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x[i].first, &x[i].second);
		sum += x[i].second;
	}
	for (int i = 0; i < m; i++)
		scanf("%d%d%d", &y[i].second.first, &y[i].second.second, &y[i].first);
	sort(y, y + m);
	long long ans = 0;
	for (int i = m - 1; i >= 0; i--) {
		if (sum <= y[i].second.second) {
			ans += sum*y[i].first;
			cout << ans;
			return 0;
		}
		ans += y[i].second.second*y[i].first;
		sum -= y[i].second.second;
	}
	cout << ans;
}