import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Solution {
	public static final boolean std = false;
	public static final String ioFile = "fisher";
	
	public final Scanner in;
	public final PrintWriter out;
	
	public Solution() throws IOException {
		if (std) {
			in = new Scanner(System.in);
			out = new PrintWriter(System.out);
		} else {
			in = new Scanner(new File(ioFile+".in"));
			out = new PrintWriter(new File(ioFile+".out"));
		}
		run();
		in.close();
		out.close();
	}

	public static void main(String[] args) throws Exception {
		new Solution();
	}


	Comparator<Base> cmp1 = (u, v) -> {
		return Long.compare(v.c, u.c);
	};
	
	
	int n, m;
	long p, ans = 0;
	Base[] all;
	void run() {
		n = in.nextInt();
		m = in.nextInt();
		p = in.nextInt();
		all = new Base[n+m];
		for (int i=0; i<n; i++) {
			all[i] = new Base(i, in.nextInt(), false, in.nextInt(), 0, 0);
		}
		for (int i=0; i<m; i++) {
			all[i+n] = new Base(i, in.nextInt(), true, 0, in.nextInt(), in.nextInt());
		}
		
		Arrays.sort(all);
		long curFish = 0;
		List<Base> cons = new ArrayList<>();
		for (int i=0; i<all.length; i++) {
			curFish += all[i].a;
			if (all[i].c > 0) {
				cons.add(all[i]);
				Collections.sort(cons, cmp1);
			}
			long nowFish = curFish, nowAns = -all[i].x * p;
			for (Base cn : cons) {
				long k = Math.min(nowFish, cn.b);
				nowFish -= k;
				nowAns += k * cn.c;
//				out.printf("%d %d %n", cn.x, k);
			}
			ans = Math.max(ans, nowAns);
		}
		
		out.println(ans);
	}
	
	class Base implements Comparable<Base> {
		public final long x;
		public final boolean type;
		public final long a, b, c;
		public final int id;
		
		public Base(int i, int pos, boolean t, int aa, int bb, int cc) {
			id = i;
			x = pos;
			type = t;
			a = aa;
			b = bb;
			c = cc;
		}
		
		@Override
		public int compareTo(Base r) {
			if (x != r.x)
				return Long.compare(x, r.x);
			if (type != r.type)
				return Boolean.compare(type, r.type);
			return Integer.compare(id, r.id);
		}
	}
}
