#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

#define SIZE 50228
#define ll long long

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

struct Base
{
	int y, b, c;
	Base() {}
};

int n, m, p;
Fish a[SIZE];
Base b[SIZE];

bool money(Base a, Base b)
{
	return a.c > b.c || (a.c == b.c && a.y < b.y);
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> p;
	for (int i = 0; i < n; i++)
		cin >> a[i].x >> a[i].a;
	for (int i = 0; i < m; i++)
		cin >> b[i].y >> b[i].b >> b[i].c;
	ll summ = 0;
	for (int i = 0; i < n; i++)
		summ += a[i].a;
	if (p == 0)
	{
		ll ans = 0;
		sort(b, b + m, money);
		for (int i = 0; i < m; i++)
		{
			if (summ >= b[i].b)
			{
				ans += b[i].b * b[i].c;
				summ -= b[i].b;
			}
			else
			{
				ans += summ * b[i].c;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}