#include <bits/stdc++.h>

using namespace std;

#define filename "fisher"

typedef long long int64;

int n, m;
int64 p;
vector<int64> x, y, a, b, c;

void solve1() {
    long long ans = 0ll;
    long long s = 0ll;
    for (int64 i : a)
        s += i;
    vector< pair<int64, int> > cost;
    for (int i = 0; i < m; i++)
        cost.push_back({c[i], i});
    sort(cost.rbegin(), cost.rend());

    for (auto i : cost)
        if (s > 0ll) {
            long long cnt = min(s, b[i.second]);
            s -= cnt;
            ans += cnt * i.first;
        }
    cout << ans << endl;
    exit(0);
}

void solve2() {
    long long ans = 0ll;
    long long s = 0ll;
    for (int64 i : a)
        s += i;
    vector< pair<int64, int> > cost;
    for (int i = 0; i < m; i++)
        cost.push_back({c[i], i});
    sort(cost.rbegin(), cost.rend());

    for (auto i : cost)
        if (s > 0ll) {
            long long cnt = min(s, b[i.second]);
            s -= cnt;
            ans += cnt * i.first;
        }

    ans -= x[n - 1] * p;

    cout << max(ans, 0ll) << endl;
    exit(0);

}

void solve3() {

}

int main() {
    ios_base::sync_with_stdio(false);

#ifndef SCHEMTSCHIK
    freopen(filename".in", "r", stdin);
    freopen(filename".out", "w", stdout);
#endif

    cin >> n >> m >> p;
    x.resize(n), a.resize(n);
    y.resize(m), b.resize(m), c.resize(m);

    for (int i = 0; i < n; i++)
        cin >> x[i] >> a[i];
    for (int i = 0; i < m; i++)
        cin >> y[i] >> b[i] >> c[i];

    if (p == 0ll)
        solve1();
    else if (y[m - 1] < x[0])
        solve2();
    else
        solve3();

    return 0;
}