#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main(){
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);

    long long n,m,p;
    scanf("%lld %lld %lld", &n, &m, &p);

    if (p == 0){
        vector<pair<long long,long long> > asel(m);

        long long mass = 0;
        for (int i = 0; i < n; i++){
            long long xr1, xr2;
            scanf("%lld %lld", &xr1, &xr2);
            mass += xr2;
        }

        for (int i = 0; i < m; i++){
            int xr;
            scanf("%lld %lld %lld", &xr, &asel[i].second, &asel[i].first);
            asel[i].first *= -1;
        }

        stable_sort(asel.begin(), asel.end());

        /*
        for (int i = 0; i < m; i++){
        printf("%lld %lld\n", asel[i].first, asel[i].second);
        }*/

        long long out = 0;
        for (int i = 0; i < m; i++){
            long long cena, kolvo;
            kolvo = asel[i].second;
            cena = -asel[i].first;
            if (mass > kolvo){
                out += kolvo*cena;
                mass -= kolvo;
            }
            else{
                out += mass*cena;
                mass = 0;
            }
        }

        printf("%lld", out);

        return 0;
    }

    vector<long long> x(n);
    vector<long long> a(n);
    vector<long long> y(m);
    vector<long long> b(m);
    vector<long long> c(m);

    for (int i = 0; i < n; i++){
        scanf("%lld %lld", &x[i], &a[i]);
    }

    for (int i = 0; i < m; i++){
        scanf("%lld %lld %lld", &y[i], &b[i], &c[i]);
    }

    if (y[m-1] <= x[0]){
        vector<pair<long long,long long> > asel(m);
        for (int i = 0; i < m; i++){
            asel[i].first = -c[i];
            asel[i].second = b[i];
        }

        stable_sort(asel.begin(), asel.end());

        int ukas = 0;
        long long maxx = 0;
        long long tec = 0;
        long long xp = 0;

        for (int i = 0; i < n; i++){
            tec -= (x[i] - xp)*p;
            xp = x[i];
            while (ukas < m && a[i] > 0){
                if (a[i] > asel[ukas].second){
                    tec -= asel[ukas].first*asel[ukas].second;
                    a[i] -= asel[ukas].second;
                    asel[ukas].second = 0;
                    ukas++;
                }
                else{
                    tec -= a[i]*asel[ukas].first;
                    asel[ukas].second -= a[i];
                    a[i] = 0;
                }
            }
            maxx = max(tec, maxx);
            //printf("%lld ", tec);
        }
        printf("%lld", maxx);
        return 0;
    }

    int ukasx = 0;
    int ukasy = 0;
    long long mass = 0;
    long long maxx = 0;
    multiset<pair<long long, long long> > mset;
    multiset<pair<long long, long long> >::iterator it;
    while (ukasx < n && ukasy < m){
        long long trai = 0;
        if (ukasy == m || (ukasx != n && x[ukasx] < y[ukasy])){
            ukasx++;
            trai -= p*x[ukasx-1];
            mass += a[ukasx-1];
        }
        else{
            ukasy++;
            trai -= p*y[ukasy-1];
            mset.insert(pair<long long, long long>(-c[ukasy-1], b[ukasy-1]));
        }

        long long mas = mass;
        for (it = mset.begin(); it != mset.end(); it++){
            long long cena = -(it->first);
            long long kolvo = it->second;
            if (mas > kolvo){
                trai += cena*kolvo;
                mas -= kolvo;
            }
            else{
                trai += cena*mas;
                mas = 0;
            }
        }

        maxx = max(maxx, trai);

        //printf("%lld ", trai);
    }
    printf("%lld", maxx);

}
/*

if (a[i] > asel[ukas].second){
                    tec -= asel[ukas].first*asel[ukas].second;
                    a[i] -= asel[ukas].second;
                    asel[ukas].second = 0;
                    ukas++;
                }
                else{
                    tec -= a[i]*asel[ukas].first;
                    asel[ukas].second -= a[i];
                    a[i] = 0;
                }


    vector<pair<long long,long long> > alov(n);
    vector<pair<long long,pair<long long,long long> > > asel(m);

    for (int i = 0; i < n; i++){
        scanf("%lld %lld", &alov[i].first, &alov[i].second);
    }

    for (int i = 0; i < m; i++){
        scanf("%lld %lld %lld", &asel[i].first, &asel[i].second.first, &asel[i].second.second);
    }

    stable_sort(alov.begin(), alov.end());
    stable_sort(asel.begin(), asel.end());
    for (int i = 0; i < n; i++){
        printf("%lld %lld\n", alov[i].first, alov[i].second);
    }
    printf("\n");
    for (int i = 0; i < m; i++){
        printf("%lld %lld %lld\n", asel[i].first, asel[i].second.first, asel[i].second.second);
    }
    */
