#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

    ifstream cin("fisher.in");
    ofstream cout("fisher.out");
struct node {
    node *l, *r;
    long long money, honey;
    void update() {
        if (l) {
            money = (l->money) + (r->money);
            honey = (l->honey) + (r->honey);
        }
    }
    node(){}
    node(long long money_, long long honey_) {
        money = money_;
        honey = honey_;
    }
    node(node *l_, node *r_) {
        l = l_;
        r = r_;
        update();
    }
    void set(int ml, int mr, int qp, long long mon, long long hon) {
        //cout << "set " << qp << ' ' << mon <<' ' << hon << endl;
        if (mr - ml == 1){
            money = mon * hon;
            honey = hon;
            return;
        }
        if (mr <= qp || qp < ml)
            return;
        if (qp < (mr + ml) / 2)
            l->set(ml, (ml + mr)/2, qp, mon, hon);
        else
            r->set((ml + mr)/2, mr, qp, mon, hon);
        update();
        //cout << "now " << money << endl;
    }
    long long spend(long long ml, long long mr, long long hon) {
        if (honey <= 0)
            return 0;
        if (mr - ml == 1)
            return money / honey * hon;
        if (hon >= honey)
            return money;
        return (l->spend(ml, (ml + mr)/2, min(honey, l->honey))) + (r->spend((ml + mr)/2, mr, hon - min(honey, l->honey)));

    }
};

node *build(int l, int r) {
    if (r - l == 1)
        return new node(0ll, 0ll);
    return new node(build(l, (l + r)/2), build((l + r)/2, r));
}

struct event{
    long long time, am;
    long long mon;
    event(long long time_, long long am_, long long mon_ = -1) {
        time = time_;
        am = am_;
        mon = mon_;
    }
    event(){}
};

bool operator<(const event &a, const event &b) {
    return a.time < b.time;
}

struct market {
    long long lim, pr;
    int id;
    market(long long l, long long p, int i) {
        lim = l;
        pr = p;
        id = i;
    }
};

bool operator<(const market &a, const market &b) {
    return a.pr < b.pr;
}

vector <market> mks;

int main() {
    long long n, m, p, c1, c2, c3;
    cin >> n >> m >> p;
    event evs[n + m];
    for(int i = 0; i < n; i++) {
        cin >> c1 >> c2;
        evs[i] = event(c1, c2);
    }
    for(int i = 0; i < m; i++) {
        cin >> c1 >> c2 >> c3;
        evs[i + n] = event(c1, c2, c3);
    }
    sort(evs, evs + n + m);
    long long res = 0;
    for (int i = 0; i < n + m; i++) {
        if (evs[i].mon != -1)
            mks.push_back(market(evs[i].am, evs[i].mon, i));
    }
    sort(mks.rbegin(), mks.rend());
    int revers[n + m];
    for (int i = 0; i < m; i++)
        revers[mks[i].id] = i;
    node *maks = build(0, m);
    long long total_fish;
    for (int i = 0; i < n + m; i++) {
        if (evs[i].mon == -1)
            total_fish += evs[i].am;
        else
            maks->set(0, m, revers[i], evs[i].mon, evs[i].am);
        res = max(res, (maks->spend(0, m, total_fish)) - evs[i].time * p);
    }
    cout << res;
    //cout << (maks->spend(0, m, 13));
    return 0;
}
