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

using namespace std;

typedef long long ll;

mt19937 rnd(218);

struct Treap {
    ll sum, sum2, b, c;
    int cnt, prior;
    Treap *tl, *tr;
    Treap(ll _b, ll _c) : sum(_b), sum2((ll)_b * _c), b(_b), c(_c), cnt(1), prior(rnd()), tl(NULL), tr(NULL) {}
};

int get_cnt(Treap *t) {
    return t == NULL ? 0 : t->cnt;
}

ll get_sum(Treap *t) {
    return t == NULL ? 0 : t->sum;
}

ll get_sum2(Treap *t) {
    return (t == NULL) ? 0 : t->sum2;
}

void update(Treap *t) {
    t->cnt = get_cnt(t->tl) + get_cnt(t->tr) + 1;
    t->sum = t->b + get_sum(t->tl) + get_sum(t->tr);
    t->sum2 = (ll)t->b * t->c + get_sum2(t->tl) + get_sum2(t->tr);
}

void split(Treap *t, int cnt, Treap *&tl, Treap *&tr) {
    if (t == NULL) {
        tl = tr = NULL;
        return;
    }
    if (cnt <= get_cnt(t->tl)) {
        split(t->tl, cnt, tl, tr);
        t->tl = tr;
        tr = t;
    } else {
        split(t->tr, cnt - get_cnt(t->tl) - 1, tl, tr);
        t->tr = tl;
        tl = t;
    }
    update(t);
}

void merge(Treap *tl, Treap *tr, Treap *&t) {
    if (tl == NULL) {
        t = tr;
        return;
    }
    if (tr == NULL) {
        t = tl;
        return;
    }
    if (tl->prior < tr->prior) {
        merge(tl->tr, tr, tl->tr);
        t = tl;
    } else {
        merge(tl, tr->tl, tr->tl);
        t = tr;
    }
    update(t);
}

int lower_bound(Treap *t, int c) {
    if (t == NULL) {
        return 0;
    } else if (t->c == c) {
        return get_cnt(t->tl);
    } else if (t->c < c) {
        return get_cnt(t->tl) + 1 + lower_bound(t->tr, c);
    } else {
        return lower_bound(t->tl, c);
    }
}

int suffix_sum(Treap *t, ll A) {
    if (get_sum(t) <= A) {
        return 0;
    };
    ll r_sum = get_sum(t->tr);
    if (r_sum + t->b > A) {
        return get_cnt(t->tl) + 1 + suffix_sum(t->tr, A);
    } else {
        return suffix_sum(t->tl, A - r_sum - t->b);
    }
}

int rightest_c(Treap *t) {
    if (t->tr != NULL) {
        return rightest_c(t->tr);
    } else {
        return t->c;
    }
}

void insert(Treap *&t, Treap *node, int cnt) {
    if (t == NULL) {
        t = node;
        return;
    }
    if (node->prior < t->prior) {
        Treap *tl, *tr;
        split(t, cnt, tl, tr);
        node->tl = tl;
        node->tr = tr;
        update(node);
        t = node;
        return;
    }
    if (cnt <= get_cnt(t->tl)) {
        insert(t->tl, node, cnt);
    } else {
        insert(t->tr, node, cnt - get_cnt(t->tl) - 1);
    }
    update(t);
}

void insert(Treap *&t, int b, int c) {
    int cnt = lower_bound(t, c);
    insert(t, new Treap(b, c), cnt);
}

ll ans(Treap *&t, ll A) {
    int cnt = suffix_sum(t, A);
    Treap *tl, *tr;
    split(t, cnt, tl, tr);
    ll _ans = get_sum2(tr);
    int c = tl == NULL ? 0 : rightest_c(tl);
    _ans += (A - get_sum(tr)) * c;
    merge(tl, tr, t);
    return _ans;
}

const bool X = false, Y = true;

struct Event {
    int pos;
    bool type;
    int idx;
    bool operator <(const Event &e) const {
        return pos < e.pos || (pos == e.pos && type == X && e.type == Y);
    }
};

int main() {
#ifndef LOCAL
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> x(n), a(n), y(m), b(m), c(m);
    vector<Event> evts(n + m);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> a[i];
        evts[i] = Event{x[i], X, i};
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i] >> b[i] >> c[i];
        evts[n + i] = Event{y[i], Y, i};
    }

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

    ll A = 0;
    ll best_ans = 0;
    Treap *root = NULL;
    for (Event &e : evts) {
        ll cur_ans = -e.pos * (ll)p;
        if (e.type == X) {
            A += a[e.idx];
        } else {
            insert(root, b[e.idx], c[e.idx]);
        }
        cur_ans += ans(root, A);
        best_ans = max(best_ans, cur_ans);
    }

    cout << best_ans << endl;

    return 0;
}
