#include <bits/stdc++.h>

using namespace std;

struct node {
    long long x, y, c;
};

node a[60000];
node b[60000];

bool cmp(node x, node y) {
    return (x.c > y.c || (x.c == y.c && x.x < y.x || (x.c == y.c && x.x == y.x && x.y < y.y)));
}

int main()
{
    freopen ("fisher.in", "r", stdin);
    freopen ("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].y;
        sum += a[i].y;
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i].x >> b[i].y >> b[i].c;
    }
    long long ans = 0;
    sort(b, b + m, cmp);
    for (int i = 0; i < m; i++) {
        if (sum == 0) {
            break;
        }
        if (b[i].y < sum) {
            sum -= b[i].y;
            ans += (b[i].y * b[i].c);
        } else {
            ans += sum * b[i].c;
            sum = 0;
        }
    }
    cout << ans << endl;
    return 0;
}
