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

using namespace std;

struct spot
{
    long long pos, price;
    spot(long long a, long long b)
    {
        pos = a;
        price = b;
    }
};

struct base
{
    long long pos, amount, price;
    long long salesuntil = 0;
    long long cashuntil = 0;
    long long maxsales = 0;
    base (long long a, long long b, long long c)
    {
        pos = a;
        amount = b;
        price = c;
    }
};

bool byprice(base a, base b)
{
    return a.price > b.price;
}


bool byx(spot a, spot b)
{
    return a.pos < b.pos;
}

vector<spot> spots;
vector<base> bases;

bool generated = false;

long long optimize(long long fish)
{
    if (!generated)
    {
        long long sales = 0;
        long long cash = 0;
        sort(bases.begin(), bases.end(), byprice);
        for (int i = 0; i < bases.size(); i++)
        {
            bases[i].salesuntil = sales;
            bases[i].cashuntil = cash;
            sales += bases[i].amount;
            cash += bases[i].amount * bases[i].price;
        }
        generated = true;
    }
    int r = bases.size();
    int l = 0;
    while (r - l > 1)
    {
        int m = (r + l) / 2;
        if (bases[m].salesuntil < fish)
        {
            l = m;
        }
        else
        {
            r = m;
        }
    }
    cerr << l << " " << bases[l].amount << endl;
    return bases[l].cashuntil + min(fish - bases[l].salesuntil, bases[l].amount) * bases[l].price;
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    long long n, m, p;
    cin >> n >> m >> p;
    long long totalfish = 0;
    for (long long i = 0; i < n; i++)
    {
        long long a, b;
        cin >> a >> b;
        spots.push_back(spot(a, b));
        totalfish += b;
    }
    for (long long i = 0; i < m; i++)
    {
        long long a, b, c;
        cin >> a >> b >> c;
        bases.push_back(base(a, b, c));
    }
    if (p == 0)
    {
        sort(bases.begin(), bases.end(), byprice);
        long long basenow = 0;
        long long totalcash = 0;
        while (basenow < m && totalfish > 0)
        {
            totalcash += min(totalfish * bases[basenow].price, bases[basenow].amount * bases[basenow].price);
            totalfish = max(0LL, totalfish - bases[basenow].amount);
            basenow++;
        }
        cout << totalcash << endl;
    }
    else
    {
        totalfish = 0;
        long long rollingmax = 0;
        long long rollingtotal = 0;
        sort(spots.begin(), spots.end(), byx);
        for (int i = 0; i < n; i++)
        {
            rollingtotal = -p * spots[i].pos;
            totalfish += spots[i].price;
            rollingtotal += optimize(totalfish);
            cerr << rollingtotal << endl;
            rollingmax = max(rollingmax, rollingtotal);
        }
        cout << rollingmax << endl;
    }
    return 0;
}
