#include <bits/stdc++.h>

using namespace std;

int main(){
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m;
    long long p;
    cin >> n >> m >> p;
    vector <long long> x(n), a(n);
    for (int i = 0; i < n; i++){
        cin >> x[i] >> a[i];
    }
    vector <long long> y(m), b(m), c(m);
    vector < pair <long long, long long> > pr(m);
    for (int i = 0; i < m; i++)
        cin >> y[i] >> b[i] >> c[i];
    x.push_back(2000000000);
    y.push_back(2000000000);
    int ukx = -1, uky = -1, ukpr = -1;
    long long ma = 0, ans = 0, kol = 0, kop;
    for (int i = 0; i < n+m; i++){
        ans = 0;
        if (x[ukx+1] > y[uky+1]){
     //       cout << "y" << " ";
            uky++;
            pr.push_back(make_pair(c[uky], b[uky]));
            sort(pr.begin(), pr.end());
            reverse(pr.begin(), pr.end());
            kop = kol;
            for (int j = 0; j < pr.size(); j++){
                ans += min(kop, pr[j].second) * pr[j].first;
                kop = max((long long)(0), kop - pr[j].second);
   //             cout << ans << " " << kop << " " << pr[j].first << "\n";
            }
 //           cout << ans << "\n";
            ans -= p*y[uky];
            ma = max(ans, ma);
        }
        else{
//            cout << "x" << " ";
            ukx++;
            kol += a[ukx];
            kop = kol;
            for (int j = 0; j < pr.size(); j++){
                ans += min(kop, pr[j].second) * pr[j].first;
                kop = max((long long)(0), kop - pr[j].second);
            }
            ans -= p*x[ukx];
            ma = max(ans, ma);
        }
  //      cout << ma << " " << ans << "\n";
    }
    cout << ma << "\n";
    return 0;
}
