import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class C {
	static int n, m, p;
	static int[][] fish;
	static int[][] markets;

	static void read() throws IOException {
		BufferedReader in = new BufferedReader(new FileReader("fisher.in"));
		StringTokenizer st = new StringTokenizer(in.readLine());
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		p = Integer.parseInt(st.nextToken());
		fish = new int[n][2];
		markets = new int[m][3];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(in.readLine());
			fish[i][0] = Integer.parseInt(st.nextToken());
			fish[i][1] = Integer.parseInt(st.nextToken());
		}
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(in.readLine());
			markets[i][0] = Integer.parseInt(st.nextToken());
			markets[i][1] = Integer.parseInt(st.nextToken());
			markets[i][2] = Integer.parseInt(st.nextToken());
		}
		in.close();
	}

	static long solution1() {
		long totalFish = 0;
		for (int i = 0; i < n; i++)
			totalFish += fish[i][1];
		Comparator<int[]> comp = new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[2], o2[2]);
			}
		};
		Arrays.sort(markets, comp);
		long profit = 0;
		for (int i = m - 1; i >= 0; i--) {
			if (totalFish <= markets[i][1]) {
				profit += 1L * markets[i][2] * totalFish;
				break;
			}
			totalFish -= markets[i][1];
			profit += 1L * markets[i][2] * markets[i][1];
		}
		return profit;
	}

	public static void main(String[] args) throws IOException {
		read();
		long ans = 0;
		if (p == 0) {
			ans = solution1();
		}
		PrintWriter out = new PrintWriter("fisher.out");
		out.print(ans);
		out.close();
	}

}
