#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstdio>
#include <map>
#define ALL(x) x.begin(),x.end()

using namespace std;


pair<long long,long long> t[2000100];


int n,m,ms2=1;

struct tree{
    int x;
    long long b,c;
    bool operator< (const tree & t) const {
        return c>t.c;
    }
    void print() {
        cout<<x<<" "<<b<<" "<<c<<endl;
    }
};

bool cmp(const tree &a, const tree &b) {
    return a.x<b.x;
}


long long get_ans(long long cur) {
   // cout<<endl;
    long long ans=0;
    int i=1;
l:
   // cout<<i<<"~"<<cur<<endl;
    if (i>=ms2+m) return ans;
    if (i>=ms2) return ans + min(cur,t[i].second)*t[i].first;
    if (cur>=t[i].second) return ans+t[i].first;
    if (t[i*2].second <= cur) {
        cur-=t[i*2].second;
        if (i*2>=ms2) ans+=t[i*2].first*t[i*2].second; else
        ans+=t[i*2].first;
        i=i*2+1;
    } else i*=2;
    goto l;
}

long long p=0;

int main () {
    freopen("fisher.in","r",stdin);
    freopen("fisher.out","w",stdout);
    cin>>n>>m>>p;
    while (ms2<m) ms2*=2;
    vector<pair<long long,long long> > v(n);
    for (int i=0;i<n;i++) scanf("%lld%lld",&v[i].first,&v[i].second);//cin>>v[i].first>>v[i].second;
    vector<tree> vp(m);
   // for (int i=0;i<ms2;i++) vp[i]
    for (int i=0;i<m;i++) scanf("%i%lld%lld",&vp[i].x,&vp[i].b,&vp[i].c);//cin>>vp[i].x>>vp[i].b>>vp[i].c;
    sort(ALL(vp));
   // reverse(ALL(v));
    /*for (int i=0;i<ms2;i++) mas[i] = 10000000070ll;
    for (int i=ms2;i<m+ms2;i++) mas[i] = vp[i-ms2].y;
    for (int i=m+ms2;i<2000100;i++) mas[i]=0;
*/
  //  return 0;
    for (int i=0;i<m;i++) t[i+ms2].first = vp[i].c;
    for (int i=0;i<ms2;i++) t[i].first = 0;
    for (int i=ms2+m;i<2000100;i++) t[i].first = 0;
    for (int i=0;i<2000100;i++) t[i].second =0 ;
  // return 0;
  //  for (int i=0;i<=ms2+m;i++) cout<<t[i].first<<","<<t[i].second<<" ";
   // cout<<endl;
   // return 0;
    sort(ALL(vp),cmp);
    cout<<endl;

  //  for (int i=0;i<m;i++) vp[i].print();



    int it1 =0 , it2 = 0;
    long long best = 0;
    long long cur =0;
    while (true) {
       if (it1 == v.size() && it2 == vp.size()) {
           cout<<best;
           return 0;
       }
       if (it1 == v.size()) {
           int l = ms2;
           int r = ms2+m;
           while (r>l+1) {
              int mid = (r+l)/2;
              if (t[mid].first<vp[it2].c) r=mid; else l=mid;
           }
           t[l].second += vp[it2].b;
           for (int i=l/2;i>0;i--) {
                t[i].second = t[i*2].second + t[i*2+1].second;
                if (i*2>=ms2) t[i].first = t[i*2].first*t[i*2].second + t[i*2+1].first*t[i*2+1].second;
                   else t[i].first = t[i*2].first + t[i*2+1].first;
           }
         //  cout<<l<<endl;
         //  for (int i=0;i<=ms2+m;i++) cout<<t[i].first<<","<<t[i].second<<" ";
         //  cout<<endl;
           best = max(best,get_ans(cur)-vp[it2].x*p);
           it2++;
       } else
       if (it2 == vp.size() ) {
           cur += v[it1].second;
           best = max(best,get_ans(cur)-v[it1].first*p);
           it1++;
       } else if (v[it1].first<vp[it2].x)  {
           cur += v[it1].second;
           best = max(best,get_ans(cur)-v[it1].first*p);
           it1++;
       } else {
           int l = ms2;
           int r = ms2+m;
           while (r>l+1) {
              int mid = (r+l)/2;
              if (t[mid].first<vp[it2].c) r=mid; else l=mid;
           }
           t[l].second += vp[it2].b;
           for (int i=l/2;i>0;i--) {
                t[i].second = t[i*2].second + t[i*2+1].second;
                if (i*2>=ms2) t[i].first = t[i*2].first*t[i*2].second + t[i*2+1].first*t[i*2+1].second;
                   else t[i].first = t[i*2].first + t[i*2+1].first;
           }
         //  cout<<l<<endl;
          // for (int i=0;i<=ms2+m;i++) cout<<t[i].first<<","<<t[i].second<<" ";
          // cout<<endl;
           best = max(best,get_ans(cur)-vp[it2].x*p);
           it2++;
       }

    }
    return 0;
 }
