#include <iostream>
#include <stdio.h>
#include <set>
#include <vector>

using namespace std;

vector<pair<long long, long long> > vn;
vector<pair<long long, pair<long long, long long> > > vm;
multiset<pair<long long, long long> > s;

signed main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    long long n, m, p, res = 0, allfish = 0, flag1 = 1;
    cin >> n >> m >> p;
    vn.resize(n);
    vm.resize(m);
    for (long long i = 0; i < n; ++i) {
        long long t1, t2;
        cin >> t1 >> t2;
        vn[i] = make_pair(t1, t2);
        allfish += t2;
    }
    for (long long i = 0; i < m; ++i) {
        long long t1, t2, t3;
        cin >> t1 >> t2 >> t3;
        vm[i] = make_pair(t1, make_pair(t2, t3));
    }
    /*long long ln = 0, lm = 0, cor = 0, top = 0, fish = 0, solve = 0;
    while (ln < vn.size() && lm < vm.size()) {
        if (lm == vm.size() || vm[lm].first >= vn[ln].first) {

        }
    }*/
    if (p == 0) {
        for (long long i = 0; i < m; ++i) {
            s.insert(make_pair(vm[i].second.second, vm[i].second.first));
        }
        while (s.size() > 0 && allfish > 0) {
            auto t1 = s.end();
            --t1;
            auto p1 = (*t1);
            s.erase(t1);
            if (allfish > p1.second) {
                res += p1.second * p1.first;
                allfish -= p1.second;
            }
            else {
                res += p1.first * allfish;
                allfish = 0;
            }
        }
        cout << res << endl;
        return 0;
    }
    //cout << vm[vm.size() - 1].first << " " << vn[0].first << endl;
    if (vm[vm.size() - 1].first < vn[0].first) {

        for (long long i = 0; i < m; ++i) {
            s.insert(make_pair(vm[i].second.second, vm[i].second.first));
        }
        long long nowres = 0, nowfish = 0;
        for (long long i = 0; i < n; ++i) {
            if (i == 0) {
                nowres -= p * vn[0].first;
            }
            else {
                nowres -= p * (vn[i].first - vn[i - 1].first);
            }
            nowfish += vn[i].second;
            //cout << nowfish << " " << nowres << " / ";
            while (s.size() > 0 && nowfish > 0) {
                auto t1 = s.end();
                --t1;
                auto p1 = (*t1);
                s.erase(t1);
                if (nowfish > p1.second) {
                    nowres += p1.second * p1.first;
                    nowfish -= p1.second;
                }
                else {
                    nowres += p1.first * nowfish;
                    s.insert(make_pair(p1.first, p1.second - nowfish));
                    nowfish = 0;
                }
            }
            //cout << nowfish << " " << nowres << endl;
            res = max(res, nowres);
        }
        cout << res << endl;
        return 0;
    }
    return 0;
}
