#include <iostream>
#include <c++/set>
#include <vector>
#include <c++/algorithm>
 
using namespace std;
 
struct my
{
    int y, buy, price;
};
 
istream & operator >> (istream & in, my & a)
{
    in >> a.y >> a.buy >> a.price;
    return in;
}
 
bool cmp(my & a, my & b)
{
    return a.price > b.price;
}
 
int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    if (p == 0)
    {
        int i;
        unsigned long long fish = 0;
        for (i = 0; i < n; i++)
        {
            int a, b;
            cin >> a >> b;
            fish += b;
        }
        multiset<pair<long long, unsigned long long>> our;
        for (i = 0; i < m; i++)
        {
            int a, b, c;
            cin >> a >> b >> c;
            our.insert(make_pair(c, b));
        }
        unsigned long long res = 0;
        while (fish > 0 && !our.empty())
        {
            auto t = our.end();
            t--;
            auto c = *t;
            our.erase(t);
            long long take = min(fish, c.second);
            fish -= take;
            res += take * c.first;
        }
        cout << res;
        return 0;
    }
    vector<pair<int, int>> ctch(n);
    vector<my> sell(m);
    int i;
    for (i = 0; i < n; i++)
        cin >> ctch[i].first >> ctch[i].second;
    for (i = 0; i < m; i++)
        cin >> sell[i];
    if (sell[m - 1].y < ctch[0].first)
    {
        sort(sell.begin(), sell.end(), cmp);
        long long res = 0;
        int here = 0;
        long long curr = 0;
        for (i = 0; i < n; i++)
        {
            auto caught = ctch[i].second;
            while (caught > 0 && here < m)
            {
                long long take = min(caught, sell[here].buy);
                caught -= take;
                curr += take * sell[here].price;
                sell[here].buy -= take;
                if (sell[here].buy <= 0)
                    here++;
            }
            res = max(res, curr - p * ctch[i].first);
        }
        cout << res;
    }
}