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

public class main {
	String fileName = "fisher";

	class pair implements Comparable<pair> {
		@Override
		public String toString() {
			return "pair [a=" + a + ", b=" + b + ", i=" + i + "]";
		}

		long a;
		long b;
		long i;

		pair(long a, long b, long i) {
			this.a = a;
			this.b = b;
			this.i = i;
		}

		@Override
		public int compareTo(pair q) {
			if (this.i > q.i)
				return -1;
			if (this.i < q.i)
				return 1;
			if (this.b > q.b)
				return -1;
			if (this.b < q.b)
				return 1;
			if (this.a > q.a)
				return -1;
			if (this.a < q.a)
				return 1;
			
			return 0;
		}
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int p = nextInt();
		pair[] x = new pair[n];
		for(int i = 0; i < n; i++){
			x[i] = new pair(nextLong(), nextLong(), i);
		}
		pair[] y = new pair[m];
		for (int i = 0; i < m; i++){
			y[i]= new pair(nextLong(), nextLong(), nextLong());
		}
		if (p == 0){
			long num = 0;
			for (int i = 0; i < x.length; i++) {
				num += x[i].b;
			}
			long res = 0;
			Arrays.sort(y);
			for (int i = 0; i < m; i++){
				if (num == 0)
					break;
				if (num >= y[i].b){
					res += y[i].b * y[i].i;
					num -= y[i].b;
				}else{
					res += num * y[i].i;
					num = 0;
				}
			}
			out.println(res);
		}else if (x[0].a > y[m - 1].a){
			Arrays.sort(y);
			long res = 0;
			int ind = 0;
			long cur = 0;
			long sum = 0;
			for (int i = 0; i < n; i++){
				cur = x[i].a * p;
				while (ind < m && x[i].b > 0){
					if (y[ind].b <= x[i].b){
						sum += y[ind].b * y[ind].i;
						x[i].b -= y[ind].b;
						ind += 1;
					}else{
						sum += x[i].b * y[ind].i;
						y[ind].b -= x[i].b;
						x[i].b = 0;
					}
				}
				res = Math.max(sum - cur, res);
			}
			out.println(res);
		}else{
			long res = 0;
			long cur = 0;
			long sum = 0;
			long num = 0;
			for (int i = 0; i < x.length; i++) {
				num += x[i].b;
			}
			TreeSet<pair> tr = new TreeSet<pair>();
			for (int i = 0; i < m; i++){
				cur = y[i].a * p;
				long k = y[i].b;
				if (num > 0){
					if (num >= y[i].b){
						res += y[i].b * y[i].i;
						num -= y[i].b;
					}else{
						res += num * y[i].i;
						num = 0;
					}
				}
				long cur1 = k - y[i].b;
				if (num == 0 && (y[i].b > 0)){
					while (y[i].b > 0 && !tr.isEmpty()){
						pair t = tr.pollLast();
						if (t.i > y[i].i){
							tr.add(t);
						}else{
							long u = k - cur1;
							if (u >= t.b){
								cur1 += t.b;
								res -= t.b * t.i;
								res += t.b * y[i].i;
								y[i].b -= t.b;
							}else{
								cur1 += u;
								t.b -= u;
								y[i].b -= u;
								res -= u * t.i;
								res += u * y[i].i;
								tr.add(t);
							}
						}
					}
					
				}
				tr.add(new pair(y[i].a, cur1, y[i].i));
				
				sum = Math.max(sum, res);
			}
				out.println(sum);
			
		}
	}

	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 main().run();
	}

}