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

public class C {
    String fileName = "fisher";

    static class Pair implements Comparable<Pair> {
    	int x;
    	int t;
    	int id;
		public Pair(int x, int t, int id) {
			this.x = x;
			this.t = t;
			this.id = id;
		}
		@Override
		public String toString() {
			return "(" + x + ", " + t + ", " + id + ")";
		}
		@Override
		public int compareTo(Pair o) {
			if (this.x != o.x) {
				return this.x - o.x;
			} 
			if (this.t != o.t) {
				return this.t - o.t;
			}
			return this.id - o.id;
		}
    }
    
    static class Pair2 implements Comparable<Pair2> {
    	int x;
    	int t;
    	int id;
		public Pair2(int x, int t, int id) {
			this.x = x;
			this.t = t;
			this.id = id;
		}
		@Override
		public String toString() {
			return "(" + x + ", " + t + ", " + id + ")";
		}
		@Override
		public int compareTo(Pair2 o) {
			if (this.x != o.x) {
				return - (this.x - o.x);
			} 
			if (this.t != o.t) {
				return - (this.t - o.t);
			}
			return - (this.id - o.id);
		}
    }
    
    static class Pair3 implements Comparable<Pair3> {
    	long x;
    	long t;
    	int id;
		public Pair3(long x, long t, int id) {
			this.x = x;
			this.t = t;
			this.id = id;
		}
		@Override
		public String toString() {
			return "(" + x + ", " + t + ", " + id + ")";
		}
		@Override
		public int compareTo(Pair3 o) {
			if (this.x != o.x) {
				return this.x > o.x ? 1 : -1;
			} 
			if (this.t != o.t) {
				return this.t > o.t ? 1 : -1;
			}
			return this.id - o.id;
		}
    }
    
	
    
    public void solve() throws IOException {
    	int n = nextInt(), m = nextInt(), p = nextInt();
    	int[] a = new int[n + m];
    	int[] b = new int[n + m];
    	int[] c = new int[n + m];
    	
    	Pair[] w = new Pair[n + m];
    	int id = 0;
    	for (int i = 0; i < n; i++) {
    		int cx = nextInt();
    		int ca = nextInt();
    		a[id] = ca;
    		w[id] = new Pair(cx, 0, id);
    		id++;
		}
    	for (int i = 0; i < m; i++) {
    		int cx = nextInt();
    		int cb = nextInt();
    		int cc = nextInt();
    		b[id] = cb;
    		c[id] = cc;
    		w[id] = new Pair(cx, 1, id);
    		id++;
		}
    	
    	if (p == 0) {
    		long caught = 0;
        	for (int i = 0; i < n; i++) {
				caught += a[i];
			}
        	TreeSet<Pair2> s = new TreeSet<>();
        	for (int i = n; i < n + m; i++) {
				s.add(new Pair2(c[i], b[i], i));
			}
        	long sold = 0;
    		long price = 0;
    		for (Pair2 g : s) {
    			if (sold + g.t >= caught) {
    				price += 1L * g.x * (caught - sold);
    				break;
    			} else {
    				sold += g.t;
    				price += 1L * g.x * g.t;
    			}
    		}
    		out.println(price);
    		return;
    	}
    	
    	if (w[n + m - 1].x < w[0].x) {
    		TreeSet<Pair2> s = new TreeSet<>();
    		for (int i = n; i < n + m; i++) {
				s.add(new Pair2(c[i], b[i], i));
			}
    		TreeSet<Pair3> d = new TreeSet<>();
    		long sold = 0;
    		long price = 0;
    		for (Pair2 e : s) {
    			sold += e.t;
    			price += 1L * e.x * e.t;
    			d.add(new Pair3(sold, price, e.id));
    		}
    		long caught = 0;
    		long max = 0;
    		for (int i = 0; i < n; i++) {
				int cx = w[i].x;
				caught += 1L *a[i];
				Pair3 f = d.floor(new Pair3(caught, Long.MAX_VALUE, Integer.MAX_VALUE));
				if (f == null) {
					f = new Pair3(0, 0, 0);
				}
				long maxx = 1L *d.last().x;
				long pr = 0;
				if (caught >= maxx) {	
					pr = 1L *d.last().t;
				} else {
					Pair3 ccc = d.ceiling(new Pair3(caught, -1, -1));
					pr = f.t + 1L *(caught - f.x) * c[ccc.id] - 1L * p * cx;
				}
				if (pr > max) {
					max = pr;
				}
    		}
    		out.println(max);
    		return;
    	}
    	
    	
    	Arrays.sort(w);
    	
    	TreeSet<Pair2> s = new TreeSet<>();
    	long caught = 0;
    	long max = 0;
    	for (int i = 0; i < w.length; i++) {
    		Pair e = w[i];
    		int cx = e.x, ct = e.t, cid = e.id;;
    		if (ct == 0) {
    			caught += a[cid];
    		} else {
    			s.add(new Pair2(c[cid], b[cid], cid));
    		}
    		long sold = 0;
    		long price = 0;
    		for (Pair2 g : s) {
    			if (sold + g.t >= caught) {
    				price += 1L * g.x * (caught - sold);
    				break;
    			} else {
    				sold += g.t;
    				price += 1L * g.x * g.t;
    			}
    		}
    		long get = price - 1L * p * cx;
    		if (get > max) {
    			max = get;
    		}
    	}
    	
    	out.println(max);
    
    }

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

}