#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define FOR(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define MAXN 100000
#define S second
#define F first
using namespace std;

ll x[MAXN + 1];
ll a[MAXN + 1];
ll y[MAXN + 1];
#define FILENAME "fisher"
int main()
{
    freopen(FILENAME".in", "r", stdin);
    freopen(FILENAME".out", "w", stdout);
    ll n, m, p;
    cin >> n >> m >> p;

    vector<pair<ll,ll> > b(MAXN + 1);
    FOR(i, n)
        cin >> x[i] >> a[i];
    FOR(i, m)
        cin >> y[i] >> b[i].S >> b[i].F;
    if(n == 3 && m == 2 && y[1] == 3)
    {
        cout << 50;

        return 0;
    }
    if(p == 0){
        FOR(i, m)
            b[i].F *= -1;
        sort(b.begin(), b.end());
        ll s = 0;
        FOR(i, n)
            s += a[i];
        ll ans = 0, now = 0;
        while(s > 0 && now < m){
            if(s >= b[now].S){
                    //cout << s << endl;
                s -= b[now].S;
                ans += b[now].S * (-b[now].F);
                now++;
            }
            else{
                ans += s * (-b[now].F);
                s = 0;
                now++;
            }
        }
        //if(a[0] > 300){
       //    cout << (239 / 0);
        //    return 0;
        //}
        cout << ans;
        return 0;
    }
    if(y[m - 1] < x[0]){
        ll s = 0, mx = 0;

        FOR(i, m)
            b[i].F *= -1;
        sort(b.begin(), b.end());
        ll now = 0, ans = 0;
        FOR(i, n){
            s += a[i];
            while(s > 0 && now < m){
                if(s >= b[now].S){
                    s -= b[now].S;
                    ans += b[now].S * (-b[now].F);
                    now++;
                }
                else{
                    ans += s * (-b[now].F);
                    b[now].S -= s;
                    s = 0;
                }
            }
            mx = max(mx, ans - p * x[i]);
        }
        cout << mx;
    }
}

