#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int maxn = 500000;
int n, m;
ll p;
ll x[maxn], a[maxn];
ll sum = 0, ans = 0;

struct base {
    ll y, b, c;
    base(ll _y = 0, ll _b = 0, ll _c = 0): y(_y), b(_b), c(_c) {}
    friend bool operator < (base a, base b) {
        if (a.c != b.c)
            return a.c < b.c;
        if (a.y != b.y)
            return a.y < b.y;
        if (a.b != b.b)
            return a.b < b.b;
    }
};

base b[maxn];

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "wt", stdout);
    cin >> n >> m >> p;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i].y >> b[i].b >> b[i].c;
    }
    sort(b, b + m);
    for (int i = 0; sum > 0 && i < m; ++i) {
        int d = min(sum, b[i].b);
        sum -= d;
        ans += d * b[i].c;
    }
    cout << ans;
    return 0;
}

/*
3 2 0
1 5
2 3
4 5
2 2 10
3 6 5
*/
