#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
const ll inf = (ll)1e18 + 100;

struct event {
    bool type;
    ll x;
    ll a, b, c;
    event(bool type = 0, ll x = 0, ll a = 0, ll b = 0, ll c = 0) : type(type), x(x), a(a), b(b), c(c) {}
    bool operator < (event b) const {
        return x < b.x;
    }
};

const ll maxn = (ll)1e6 + 10;
ll fenw[maxn];
ll fenwb[maxn];

void upd(ll C, ll B) {
    ll c = C;
    while (c < maxn) fenw[c] += C * B, c |= (c + 1);
}

ll pref(ll C) {
    ll ans = 0;
    while (C >= 0) ans += fenw[C], C = (C & (C + 1)) - 1;
    return ans;
}

ll sum(ll l, ll r) {
    return pref(r) - (l ? pref(l - 1) : 0ll);
}

void updb(ll C, ll B) {
    ll c = C;
    while (c < maxn) fenwb[c] += B, c |= (c + 1);
}

ll prefb(ll C) {
    ll ans = 0;
    while (C >= 0) ans += fenwb[C], C = (C & (C + 1)) - 1;
    return ans;
}

ll sumb(ll l, ll r) {
    if (l > r) return 0;
    return prefb(r) - (l ? prefb(l - 1) : 0ll);
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ll n, m, p;
    cin >> n >> m >> p;
    vector<event> v;
    for (ll i = 0; i < n; ++i) {
        ll x, a;
        cin >> x >> a;
        v.pb(event(1, x, a, 0, 0));
    }
    for (ll i = 0; i < m; ++i) {
        ll y, b, c;
        cin >> y >> b >> c;
        v.pb(event(0, y, 0, b, c));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    ll A = 0;
    for (ll i = 0; i < (ll)v.size(); ++i) {
        A += v[i].a;
        upd(v[i].c, v[i].b);
        updb(v[i].c, v[i].b);
        ll cur = 0;
        ll L = 0, R = maxn - 1, M;
        while (R != L + 1) {
            M = (L + R) >> 1;
            if (sumb(M, maxn - 1) <= A) R = M;
            else L = M;
        }
        ll curA = A - sumb(R, maxn - 1);
        cur += sum(R, maxn - 1);
        cur += (R - 1) * min(sumb(R - 1, R - 1), curA);
        //cerr << v[i].x << " : " << cur << "     " << R << " " << sum(R, maxn - 1) << " " << R - 1 << endl;
        ans = max(ans, cur - p * v[i].x);
    }
    cout << ans;
    return 0;
}
/*
3 2 0
1 5
2 3
4 5
2 2 10
3 6 5
*/



