#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];
ll mx[500000];
ll sm[500000];
bool comp(int x, int y) {
    if (c[x] < c[y]) return true;
    return false;
}
int bin(int l, int r, ll x) {
    if (l + 1 >= r) {
        if (mx[r] <= x) return r;
        else return -1;
    }
    int m = (l + r) / 2;
    if (mx[m] <= x) return bin(l, m, x);
    return bin(m, r, x);
}
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 (y[m - 1] >= x[0] && p != 0) {
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
            if (x[n - 1] < y[m] && i < n - 1) continue;
            vector <pair <ll, int> > v;
            for (int j = 0; j < m; j++) {
                ll sum1 = sum;
                ll cur = 0;
                v.pb(mp(c[j], j));
                sort(v.begin(), v.end());
                for (int k = v.size() - 1; k >= 0 && sum1 > 0; k--) {
                    cur += min(sum1, b[v[k].second]) * v[k].first;
                    sum1 -= min(sum1, b[v[k].second]);
                }
                ans = max(ans, cur - p * max(x[i], y[j]));
            }
        }
        cout << ans << "\n";
        return 0;
    }
    sort(d, d + m, comp);
    mx[m - 1] = b[d[m - 1]];
    for (int i = m - 2; i >= 0; i--) mx[i] = mx[i + 1] + b[d[i]];
    sm[m - 1] = b[d[m - 1]] * c[d[m - 1]];
    for (int i = m - 2; i >= 0; i--) sm[i] = sm[i + 1] + b[d[i]] * c[d[i]];
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        ll sum1 = sum;
        ll cur = 0;
        int k = bin(-1, m - 1, sum1);
        if (k != -1) cur += sm[k];
        else k = m;
        if (k > 0) {
            k--;
            cur += (sum1 - mx[k + 1]) * c[d[k]];
        }
        ans = max(ans, cur - p * x[i]);
    }
    cout << ans << "\n";
}
