#include <bits/stdc++.h>

using namespace std;

const long long INF=(long long) 1e17;

long long n,m,p,x,a,b,c,y,sum,curans,ans,type,cost,pos,cnt;
multiset <pair <long long,long long> > s;
vector <pair <long long,pair <pair <long long,long long>,long long> > > v;

void update()
{
    //cout << "HI";
    long long kol=sum;
    long long newans=0;
    for(auto it=s.begin();it!=s.end();it++)
    {
        //cout << "HOHOH";
        if(sum==0) break;
        auto x=*it;
        x.first=-(x.first-INF);
        //cout << x.first << endl;
        newans+=min(kol,x.second)*x.first;
        kol-=min(kol,x.second);
    }
    curans+=newans;
}

int main()
{
    freopen("fisher.in","r",stdin);
    freopen("fisher.out","w",stdout);
    /*
    3 2 0
    1 5
    2 3
    4 5
    2 2 10
    3 6 5
    */
    /*
    2 1 100
    6 5
    100 4
    5 100 2000
    */
    cin >> n >> m >> p;
    for(int i=0;i<n;i++)
    {
        cin >> x >> a;
        v.push_back(make_pair(x,make_pair(make_pair(0,0),a)));
    }
    for(int i=0;i<m;i++)
    {
        cin >> y >> b >> c;
        v.push_back(make_pair(y,make_pair(make_pair(1,c),b)));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        type=v[i].second.first.first;
        pos=v[i].first;
        cnt=v[i].second.second;
        cost=v[i].second.first.second;
        //cout << type << " " << pos << " " << cnt << " " << cost << endl;
        //if(i==0) curans+=p*pos; else curans+=p*(pos-v[i-1].second.first);
        if(type==0) sum+=cnt;
        if(type==1) s.insert(make_pair(INF-cost,cnt));
        curans=0;
        update();
        //cout << i << " " << curans << endl;
        curans-=p*pos;// else curans-=p*(pos-v[i-1].first);
        ans=max(ans,curans);
    }
    cout << ans;
    return 0;
}
