#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int lim = 500000;
const int segs = 625;

ll min(ll a, ll b) {
	return (a < b ? a : b);
}

struct Fish {
	int x;
	int a;
	Fish() {}
	Fish(int x, int a) : x(x), a(a) {}
};

struct Shop {
	int x;
	int a;
	int c;
	int rank;
	Shop() {}
	Shop(int x, int a, int c) : x(x), a(a), c(c) {}
};

Fish arf[lim];
Shop ars[lim];
int sorted[lim];

bool comp(int const &a, int const &b) {
	return ars[a].c < ars[b].c;
}

int main() {
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	int n, m, p, i, x, a, c;
	scanf("%d %d %d", &n, &m, &p);
	for (i = 0; i < n; ++i) {
		scanf("%d %d", &x, &a);
		arf[i] = Fish(x, a);
	}
	for (i = 0; i < m; ++i) {
		scanf("%d %d %d", &x, &a, &c);
		ars[i] = Shop(x, a, c);
		sorted[i] = i;
	}
	sort(sorted, sorted + m, comp);
	for (i = 0; i < m; ++i)
		ars[sorted[i]].rank = i;

	ll res = 0;
	if (!p) {
		ll total = 0;
		for (i = 0; i < n; ++i)
			total += arf[i].a;
		for (i = m - 1; i >= 0; --i) {
			res += ars[sorted[i]].c * min(total, ars[sorted[i]].a);
			total -= min(total, ars[sorted[i]].a);
		}
	}
	printf("%lld", res);
	return 0;
}