#include<fstream>
#include<algorithm>

using namespace std;

ifstream cin("fisher.in");
ofstream cout("fisher.out");

bool cmp(vector<long long> a, vector<long long> b){
    return a[0] < b[0] || a[0] == b[0] && a[1] < b[1];
}

int main(){
    long long n, m, p;
    cin >> n >> m >> p;
    pair<long long, long long> x[n];
    vector<long long> y[m];
    vector<long long> ev[n + m];
    vector<long long> curm[m];
    for (long long i = 0; i < n; ++i){
        cin >> x[i].first >> x[i].second;
        ev[i].push_back(x[i].first);
        ev[i].push_back(1);
        ev[i].push_back(i);
    }
    for (long long i = 0; i < m; ++i){
        long long a, b, c;
        cin >> a >> b >> c;
        y[i].push_back(a);
        y[i].push_back(b);
        y[i].push_back(c);
        ev[n + i].push_back(a);
        ev[n + i].push_back(-1);
        ev[n + i].push_back(i);
        curm[i].push_back(c);
        curm[i].push_back(b);
        curm[i].push_back(i);
    }
    sort(ev, ev + n + m, cmp);
    sort(curm, curm + m, cmp);
    long long mx = 0;
    long long cur = 0;
    long long ind = -1;
    for (long long i = 0; i < n + m; ++i){
        if (ev[i][1] == -1){
            ind = ev[i][2];
        }
        else{
            cur += x[ev[i][2]].second;
        }
        long long cur1 = cur;
        long long p1 = 0;
        for (long long i = m - 1; i >= 0; --i){
            if (curm[i][2] > ind) continue;
            if (cur1 - curm[i][1] >= 0){
                p1 += curm[i][1] * curm[i][0];
                cur1 -= curm[i][1];
            }
            else{
                p1 += curm[i][0] * cur1;
                break;
            }
        }
        if (ev[i][1] == -1){
            mx = max(mx, p1 - p * y[ev[i][2]][0]);
        }
        else{
            mx = max(mx, p1 - p * x[ev[i][2]].first);
        }
    }
    cout << mx;
}
