#include <bits/stdc++.h>

using namespace std;

struct Ev
{
    long long x;
    bool type;

    long long a;
    long long b, c;

    Ev() {}
};

bool operator < (const Ev &e1, const Ev &e2)
{
    return (e1.x < e2.x);
}

vector<Ev> evts;
long long ans = 0;
long long p;

/// ------

long long currS = 0;
set< pair<long long, long long>, greater< pair<long long, long long> > > pr;

/// ------

void reCalc(int ind)
{
    long long res = 0;
    long long cc;
    long long junk = currS;

    for (auto it = pr.begin(); it != pr.end(); it++)
    {
        auto el = *it;

        cc = min(junk, el.second);

        res += cc * el.first;
        junk -= cc;

        /*if (junk == 0)
            break;*/
    }

    res -= p * evts[ind].x;
    ans = max(ans, res);
}

void doSmth(int ind)
{
    if (evts[ind].type == false)
        currS += evts[ind].a;
    else
        pr.insert({evts[ind].c, evts[ind].b});

    reCalc(ind);
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m >> p;

    evts.resize(n + m);

    for (int i = 0; i < n; i++)
    {
        evts[i].type = false;
        cin >> evts[i].x >> evts[i].a;
    }

    for (int i = n; i < n + m; i++)
    {
        evts[i].type = true;
        cin >> evts[i].x >> evts[i].b >> evts[i].c;
    }

    sort(evts.begin(), evts.end());

    for (int i = 0; i < n + m; i++)
        doSmth(i);

    cout << ans;

    return 0;
}
