#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
ll n, m, p;
ll x[500000];
ll a[500000];
ll y[500000];
ll b[500000];
ll c[500000];
ll d[500000];
bool comp(int x, int y) {
    if (c[x] < c[y]) return true;
    return false;
}
int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    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];
        d[i] = i;
    }
    ll ans = 0;
    if (x[n - 1] < y[0] && p != 0) {
        ll sum = 0;
        for (int i = 0; i < n; i++) sum += a[i];
        for (int i = 0; i < m; i++) {
            ll sum1 = sum;
            set <pair <ll, int> > s;
            ll cur = 0;
            for (int j = 0; j <= i; j++) s.insert(mp(-c[j], j));
            while (sum1 > 0 && s.size() > 0) {
                int j = (*(s.begin())).second;
                s.erase(mp(-c[j], j));
                cur += min(sum1, b[j]) * c[j];
                sum1 -= min(sum1, b[j]);
            }
            ans = max(ans, cur - p * y[i]);
        }
        cout << ans << "\n";
        return 0;
    }
    sort(d, d + m, comp);
    for (int i = 0; i < n; i++) {
        ll sum = 0;
        for (int j = 0; j <= i; j++) sum += a[j];
        ll cur = 0;
        int k = m - 1;
        while (sum > 0 && k >= 0) {
            cur += min(sum, b[d[k]]) * c[d[k]];
            sum -= min(sum, b[d[k]]);
            k--;
        }
        ans = max(ans, cur - p * x[i]);
    }
    cout << ans << "\n";
}
