#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

struct p {
	long long a, b;
};

struct f {
	long long a, b, c;
};

const int sz = 5e4;

p x[sz];
f y[sz];

bool comp(f a, f b) {
	return a.c > b.c;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p;
	scanf("%d%d%d", &n, &m, &p);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &x[i].a, &x[i].b);
		sum += x[i].b;
	}
	for (int i = 0; i < m; i++) {
		scanf("%lld%lld%lld", &y[i].a, &y[i].b, &y[i].c);
	}
	sort(y, y + m, comp);
	long long res = 0;
	for (int i = 0; i < m && sum > 0; i++) {
		res += min(sum, y[i].b) * y[i].c;
		sum -= y[i].b;
	}
	printf("%lld", res);
    return 0;
}

