#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

const long long  MAX = 5 * 1e5 + 13;

long long  n, m, p;

struct baza {
	long long  y, b, c;
};

struct lov{
	long long  x, a;
};

baza baz[MAX];

lov lo[MAX];

bool cmp(baza a, baza b) {
	return a.c <= b.c;
}

int main() {
	//freopen("tests.txt", "r", stdin);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	
	cin >> n >> m >> p;
	long long s = 0;
	for (long long  i = 1; i <= n; i++) {
		cin >> lo[i].x >> lo[i].a;
		s += lo[i].a;
	}
	for (long long  i = 1; i <= m; i++) {
		cin >> baz[i].y >> baz[i].b >> baz[i].c;
	}
	
	if (p == 0) {
		long long ans = 0;
		sort(baz + 1, baz + m + 1, cmp);
		for (long long  i = m; i >= 1; i--) {
			if (baz[i].b <= s) {
				ans += baz[i].b * baz[i].c;
				s -= baz[i].b;
			}
			else {
				ans += s * baz[i].c;
				s = 0;
			}
		}
		cout << ans;
		return 0;
	}

	return 0;
}