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

public class Fisher {
    String fileName = "fisher";

    public void solve() throws IOException {
        int n = nextInt(), m = nextInt(), p = nextInt();
        Event[] events = new Event[n + m];
        Selling[] sellings = new Selling[m];
        Fishing[] fishings = new Fishing[n];

        long sum = 0;
        for (int i = 0; i < n; i++) {
            events[i] = new Fishing(nextInt(), nextInt(), i);
            fishings[i] = (Fishing) events[i];
            sum += ((Fishing) events[i]).a;
        }
        for (int j = 0; j < m; j++) {
            events[n + j] = new Selling(nextInt(), nextInt(), nextInt(), j);
            sellings[j] = (Selling) events[n + j];
        }

        if (p == 0) {
            Arrays.sort(sellings, (o1, o2) -> Integer.compare(o2.c, o1.c));
            long res = 0;
            int t = 0;
            while (t < m && sum > 0) {
                if (sum >= sellings[t].b) {
                    res += (long) sellings[t].b * sellings[t].c;
                    sum -= sellings[t].b;
                } else {
                    res += sum * sellings[t].c;
                    sum = 0;
                }
                t++;
            }
            out.println(res);
        } else {
            if (events[n + m - 1].x < events[0].x) {
                long ans = -events[n + m - 1].x * p, res = ans;
                int t = 0;
                long x = events[n + m - 1].x;
                Arrays.sort(sellings, (o1, o2) -> Integer.compare(o2.c, o1.c));
                Arrays.sort(fishings, (o1, o2) -> Integer.compare(o1.x, o2.x));
                for (int q = 0; q < n; q++) {
                    res -= (fishings[q].x - x) * p;
                    long s = fishings[q].a;
                    while (t < m && s > 0) {
                        if (s >= sellings[t].b) {
                            res += ((long) sellings[t].b) * sellings[t].c;
                            s -= sellings[t].b;
                            t++;
                        } else {
                            res += s * sellings[t].c;
                            sellings[t].b -= s;
                            s = 0;
                        }
                    }
                    x = fishings[q].x;
                    ans = Math.max(ans, res);
                }
                out.println(ans);
            } else if (events[n - 1].x < events[n].x) {
                long ans = 0, res = -events[n - 1].x * p;
                long x = events[n - 1].x;
                Arrays.sort(sellings, (o1, o2) -> Integer.compare(o1.x, o2.x));
                for (int q = 0; q < m; q++) {
                    res -= (sellings[q].x - x) * p;
                    if (sum > sellings[q].b) {
                        res += ((long) sellings[q].b) * sellings[q].c;
                        sum -= sellings[q].b;
                    } else {
                        res += sum * sellings[q].c;
                    }
                    x = sellings[q].x;
                    ans = Math.max(ans, res);
                }
                out.println(ans);
            }
        }
    }

    private class Event {
        int x;
    }

    private class Fishing extends Event {
        int a, num;

        public Fishing(int x, int a, int num) {
            this.x = x;
            this.a = a;
            this.num = num;
        }
    }

    private class Selling extends Event {
        int b, c, num;

        public Selling(int x, int b, int c, int num) {
            this.x = x;
            this.b = b;
            this.c = c;
            this.num = num;
        }
    }

    private class Segment implements Comparable<Segment> {
        long a, k;
        int num;

        public Segment(long a, long k, int num) {
            this.a = a;
            this.k = k;
            this.num = num;
        }

        @Override
        public int compareTo(Segment o) {
            if (k == o.k) {
                return Integer.compare(num, o.num);
            } else {
                return Long.compare(o.k, k);
            }
        }
    }

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

}