#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <time.h>
#include <algorithm>
#include <map>

#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornn(i, q, n) for (int i = (q); i < (n); i++)
#define mp make_pair
#define times clock() * 1.0 / CLOCKS_PER_SEC
using namespace std;

typedef long long ll;

int solve();
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
	solve();
	return 0;
}

const int MAXN = 107;




int solve() {
	int n, m, p;
	cin >> n >> m >> p;
	vector<pair<int, int > > G(n), H(m);
	ll sm = 0;
	forn(i, n) {
		cin >> G[i].first >> G[i].second;
		sm += G[i].second;
	}
	forn(i, m) {
		int foo;
		cin >> foo >>  H[i].second >> H[i].first;
	}
	ll ans = 0;
	sort(H.begin(), H.end());
	reverse(H.begin(), H.end());
	forn(i, m) {
		if (sm >= H[i].second) {
			ans += H[i].first * H[i].second;
			sm -= H[i].second;
		}
		else {
			ans += H[i].first * sm;
			sm = 0;
		}
	}
	cout << ans;
	return 0;
}