#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;



int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	ll n, m, p;
	cin >> n >> m >> p;
	ll A = 0;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		A += y;
	}
	vector<pair<ll, ll>> v(m);
	for (int i = 0; i < m; i++) {
		ll x;
		cin >> x >> v[i].second >> v[i].first;
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for (int i = m - 1; i >= 0 && A > 0; i--)
		if (A >= v[i].second) {
			A -= v[i].second;
			ans += v[i].first * v[i].second;
		}
		else {
			ans += A * v[i].first;
			A = 0;
		}
	cout << ans;
	return 0;
}