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];

        long sum = 0;
        for (int i = 0; i < n; i++) {
            events[i] = new Fishing(nextInt(), nextInt(), 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.x, o1.x));
            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);
        }
    }

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

}