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

struct Ev {
    int pos;
    bool base;
    int a, b, c;
    Ev(int pos, int a) : pos(pos), base(false), a(a) {}
    Ev(int pos, int b, int c) : pos(pos), base(true), b(b), c(c) {}
};
struct Base {
    int b, c;
    Base(int b, int c) : b(b), c(c) {}
    bool operator <(Base t) const {
        return c > t.c;
    }
};

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, a));
    }
    for(int i = 0; i < m; ++i) {
        int y, b, c;
        scanf("%d%d%d", &y, &b, &c);
        ev.push_back(Ev(y, b, c));
    }
    sort(ev.begin(), ev.end(), [](const Ev &a, const Ev &b){ return a.pos < b.pos; });
    LL ans = 0;
    LL fish = 0;
    multiset<Base> bases;
    for(const Ev &e : ev) {
        if(e.base) {
            bases.insert(Base(e.b, e.c));
        } else {
            fish += e.a;
        }
        LL cur_fish = fish;
        LL cur_ans = -1LL * e.pos * p;
        for(const Base &base : bases) {
            LL take = min(cur_fish, (LL)base.b);
            cur_fish -= take;
            cur_ans += take * base.c;
            if(cur_fish == 0) {
                break;
            }
        }
        ans = max(ans, cur_ans);
    }
    printf("%I64d", ans);
    return 0;
}
