#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

struct Ev {
    int pos;
    bool base;
    int a, ci;
    Ev(int pos, bool base, int a, int ci) : pos(pos), base(base), a(a), ci(ci) {}
};
struct Base {
    int pos, b, c, ci;
    Base(int pos, int b, int c) : pos(pos), b(b), c(c), ci(-1) {}
};

int main() {
    #define FNAME "fisher"
    #ifndef LOCAL
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
    #endif
    int n, m, p;
    scanf("%d%d%d", &n, &m, &p);
    vector<Ev> ev;
    for(int i = 0; i < n; ++i) {
        int x, a;
        scanf("%d%d", &x, &a);
        ev.push_back(Ev(x, false, a, -1));
    }
    vector<Base> bases;
    for(int i = 0; i < m; ++i) {
        int y, b, c;
        scanf("%d%d%d", &y, &b, &c);
        bases.push_back(Base(y, b, c));
    }
    sort(bases.begin(), bases.end(), [](const Base &a, const Base &b){ return a.c > b.c; });
    for(int i = 0; i < m; ++i) {
        bases[i].ci = i;
        ev.push_back(Ev(bases[i].pos, true, -1, i));
    }
    sort(ev.begin(), ev.end(), [](const Ev &a, const Ev &b){ return a.pos < b.pos; });
    LL ans = 0;
    LL fish = 0;
    vector<char> base_en(m);
    for(const Ev &e : ev) {
        if(e.base) {
            base_en[e.ci] = 1;
        } else {
            fish += e.a;
        }
        LL cur_ans = -1LL * e.pos * p;
        LL cur_fish = fish;
        for(int i = 0; i < m; ++i) {
            if(base_en[i]) {
                LL take = min((LL)bases[i].b, cur_fish);
                cur_fish -= take;
                cur_ans += take * bases[i].c;
            }
        }
        ans = max(ans, cur_ans);
    }
    printf("%I64d", ans);
    return 0;
}
