#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n, m, p, x[500006], y[500006], a[500006], b[500005], c[500005];

set <pair <ll, ll> > ch, ch2;

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];
    }
    int id = 0;
    ll ans = 0;
    ll ul = 0;
    for(int i = 0; i < m; i++) {
        while(x[id] <= y[i]) {
            ul += a[id];
            if (id == n - 1) {
                break;
            }
            id++;
        }
        if (ul != 0) {
            ll ans2 = -p*y[i];
            ch2.clear();
            ch.insert(make_pair(-c[i], b[i]));
            ll ul2 = ul;
            while(ul2 != 0) {
                if (ch.empty()) {
                    break;
                }
                pair <ll, ll> ar;
                ar.first = -((ch.begin())->first);
                ar.second = (ch.begin())->second;
                ans2 += (min(ul2, ar.second)*ar.first);
                ul2 -= min(ul2, ar.second);
                ch.erase(ch.begin());
                ar.first *= (-1);
                ch2.insert(ar);
            }
            ans = max(ans, ans2);
            ch = ch2;
        }
        if (i == m - 1 && id != n - 1) {
            for(int j = id; j < n; j++) {
                ul += a[j];
                ll ans2 = -p*x[j];
               // cout << "   " << ans2 << endl;
                ch2.clear();
                ch.insert(make_pair(-c[i], b[i]));
                ll ul2 = ul;
             //   cout << "       " << ul2 << endl;
                while(ul2 != 0) {
                    if (ch.empty()) {
                        break;
                    }
                    pair <ll, ll> ar;
                    ar.first = -((ch.begin())->first);
                    ar.second = (ch.begin())->second;
                    ans2 += (min(ul2, ar.second)*ar.first);
                    ul2 -= min(ul2, ar.second);
                    ch.erase(ch.begin());
                    ar.first *= (-1);
                    ch2.insert(ar);
                }
                ans = max(ans, ans2);
                ch = ch2;
            }
        }
    }
    cout << ans;
    return 0;
}
