#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <fstream>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
#define mp make_pair

ll n, m, p, ans, a[500000], b[500000], c[500000], d1[500000], d2[500000], cost, D;

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    for (int i = 0; i < n; i++)
        cin >> d1[i] >> a[i];
    for (int i = 0; i < m; i++)
        cin >> d2[i] >> b[i] >> c[i];
    int i = 0, j = 0;
    ll sum = 0;
    set <pair <ll, pair <ll, ll> > > s, used;
    while (true){
        if (i == n && j == m)
            break;
        if ((i < n) && (j == m || d1[i] < d2[j])){
            D = d1[i];
            sum += a[i];
            i++;
        }
        else{
            D = d2[j];
            s.insert(make_pair(-c[j], make_pair(b[j], rand())));
            j++;
        }
        while (sum > 0 && !s.empty()){
            ll B = (*s.begin()).second.first, C = -(*s.begin()).first;
            if (sum >= B){
                sum -= B;
                s.erase((*s.begin()));
                used.insert(mp(C, mp(B, rand())));
                ans += C * B;
            }
            else{
                s.erase((*s.begin()));
                s.insert(make_pair(-C, make_pair(B - sum, rand())));
                used.insert(make_pair(C, make_pair(sum, rand())));
                ans += sum * C;
                sum = 0;
            }
        }
        while (!used.empty() && !s.empty() && -(*s.begin()).first > (*used.begin()).first){
            ll C1 = -(*s.begin()).first, B1 = (*s.begin()).second.first,
            C2 = (*used.begin()).first, B2 = (*used.begin()).second.first;
            if (B1 > B2){
                used.erase((*used.begin()));
                used.insert(make_pair(C1, make_pair(B2, rand())));
                s.erase((*s.begin()));
                s.insert(make_pair(-C2, make_pair(B2, rand())));
                s.insert(make_pair(-C1, make_pair(B1 - B2, rand())));
                ans = ans + B2 * (C1 - C2);
            }
            else{
                used.erase((*used.begin()));
                used.insert(make_pair(C1, make_pair(B2 - B1, rand())));
                used.insert(make_pair(C2, make_pair(B1, rand())));
                s.erase((*s.begin()));
                s.insert(make_pair(-C2, make_pair(B1, rand())));
                ans = ans + B1 * (C1 - C2);

            }
        }
        cost = max(cost, ans - D * p);
        //cout << D << ' ' << ans - D * p << endl;
    }
    cout << cost << endl;
    return 0;
}
