#include <iostream>
#include <iomanip>
#include <cstdio>

#include <cassert>
#include <cmath>
#include <algorithm>
#include <ctime>

#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <utility>

using std::cin;
using std::cout;
using std::cerr;

using std::max;
using std::min;
using std::abs;

using std::vector;
using std::pair;
using std::string;
using std::queue;
using std::set;
using std::map;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pul;

#define ff first 
#define ss second 
#define pb push_back 
#define print(a) cerr << (a) << '\n' 
#define dbg(a) cerr << #a << " = " << (a) << '\n' 
#define dbg2(a, b) cerr << #a << " = " << (a) << ' ' << #b << " = " << (b) << '\n' 
#define dbg3(a, b, c) cerr << #a << " = " << (a) << ' ' << #b << " = " << (b) << ' ' << #c << " = " << (c) << '\n' 

void init() {
	#ifndef LOCAL
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	#endif
	// std::iostream::sync_with_stdio(0);
	// cout << std::fixed << std::setprecision(10);
	// cerr << std::fixed << std::setprecision(10);
}

const int MAXN = 500000;

ll a[MAXN], x[MAXN], y[MAXN], b[MAXN], c[MAXN];

int main() {
	init();

	int n, m;
	ll p;
	cin >> n >> m >> p;
	ll one = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i] >> a[i];
		one += a[i];
	}
	std::multiset<pll, std::greater<pll>> two;
	for (int i = 0; i < m; ++i) {
		cin >> y[i] >> b[i] >> c[i];
		two.insert({c[i], b[i]});
	}
	ll ans = 0;
	while (!two.empty()) {
		auto cur = *two.begin();
		two.erase(two.begin());
		ll sell = min(one, cur.ss);
		one -= sell;
		ans += sell * cur.ff;
		if (one == 0) 
			break;
	}
	cout << ans << '\n';

	return 0;
}