import java.io.*;
import java.util.*;

public class c1 {
	String fileName = "fisher";

	static class Pair implements Comparable<Pair> {
		int x;
		int y;

		Pair(int _x, int _y) {
			x = _x;
			y = _y;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.x == o.x) {
				return this.y - o.y;
			} else {
				return this.x - o.x;
			}
		}

	}
	
	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int p = nextInt();
		
		int a[] = new int[n];
		int x[] = new int[n];
		int y[] = new int[m];
		
		int b[] = new int[m];
		int c[] = new int[m];
		
		for (int i = 0; i < n; i++) {
			x[i] = nextInt();
			a[i] = nextInt();
		}
		
		for (int i = 0; i < m; i++) {
			y[i] = nextInt();
			b[i] = nextInt();
			c[i] = nextInt();
		}
		
		if (p == 0){
			long could = 0;
			
			for (int i = 0; i < n; i++) {
				could += a[i];
			}
			
			Pair q[] = new Pair[m];
			
			for (int i = 0; i < m; i++) {
				q[i] = new Pair(c[i], b[i]);
			}
			
			Arrays.sort(q);
			
			long ans = 0;
			
			for (int i = m - 1; i > -1 && could > 0; i--) {
				long cnt = Math.min(q[i].y, could);
				ans += 1l * cnt * q[i].x;
				could -= cnt;
			}
			
			out.println(ans);
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new c1().run();
	}

}