#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

vector < pair <long long, long long> > fish;
vector < pair <long long, pair <long long, long long> > > shop;
vector < pair <long long, long long> > newshop;

long long lastshop;

long long add_income(long long addfish)
{
    long long income = 0;
    long long i;
    for(i = lastshop; i >= 0; i--)
    {
        if(addfish == 0)
            break;
        long long trade = min(addfish, newshop[i].second);
        income += trade * newshop[i].first;
        addfish -= trade;
        newshop[i].second -= trade;
    }
    lastshop = i;
    return income;
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);

    long long n, m, p;
    cin >> n >> m >> p;
    fish.resize(n);
    shop.resize(m);
    long long i, j;
    for(i = 0; i < n; i++)
        cin >> fish[i].first >> fish[i].second;
    for(i = 0; i < m; i++)
        cin >> shop[i].first >> shop[i].second.first >> shop[i].second.second;
    sort(fish.begin(), fish.end());
    sort(shop.begin(), shop.end());

    //newshop
    for(i = 0; i < m; i++)
        newshop.push_back({shop[i].second.second, shop[i].second.first});
    sort(newshop.begin(), newshop.end());

    // go go go;
    if(p == 0)
    {
        long long fishtake = 0;
        for(i = 0; i < n; i++)
        {
            fishtake += fish[i].second;
        }
        //incout
        long long income = 0;
        for(i = m - 1; i >= 0; i--)
        {
            if(fishtake == 0)
                break;
            long long trade = min(fishtake, newshop[i].second);
            income += trade * newshop[i].first;
            fishtake -= trade;
        }
        cout << income;
        return 0;
    }
    //secon case, shops in the begginging
    if((shop.back().first < fish[0].first))
    {
        long long bestincome = 0, lastincome = 0;
        long long add_inc = 0, fuel_spend = 0;
        lastshop = m - 1;
        for(i = 0; i < n; i++)
        {
            fuel_spend = (i == 0) ? fish[0].first * p : (fish[i].first - fish[i - 1].first) * p;
            add_inc = add_income(fish[i].second);
            lastincome += add_inc;
            if(lastincome > bestincome)
                bestincome = lastincome;
        }
        cout << bestincome << endl;
        return 0;
    }
}
