#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#pragma warning(disable : 4996)

using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
#endif

	int n, m, p;
	cin >> n >> m >> p;

	vector<vector<long long> > lov (n, vector<long long>(2));
	for (int i = 0; i < n; i++) {
		cin >> lov[i][0] >> lov[i][1];
	}


	vector<vector<long long> > prod(m, vector<long long>(3));
	for (int i = 0; i < m; i++) {
		cin >> prod[i][2] >> prod[i][1] >> prod[i][0];
	}
	
	long long h = 0;
	for (int i = 0; i < n; i++) {
		h += lov[i][1];
	}


	stable_sort(prod.begin(), prod.end());
	reverse(prod.begin(), prod.end());
	long long otv = 0;
	for (int i = 0; i < m; i++) {
		if (h > 0) {
			if (h > prod[i][1]) {
				h = h - prod[i][1];
				otv += prod[i][1] * prod[i][0];
			}
			else {
				otv += h * prod[i][0];
				h = 0;
			}
		}
	}
	cout << otv;
	return 0;
}