#include <bits/stdc++.h>
using namespace std;
#define ll unsigned 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;
    }
};

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;
    set<pii> s;
    ll A = 0;
    for (ll i = 0; i < (ll)v.size(); ++i) {
        if (v[i].type) A += v[i].a;
        else s.insert(mkp(v[i].c, v[i].b));
        ll cur = 0;
        ll curA = A;
        for (set<pii>::reverse_iterator j = s.rbegin(); j != s.rend() && curA > 0; ++j) {
            cur += j->F * min(curA, j->S);
            curA -= min(curA, j->S);
        }
        if (cur < p * v[i].x) continue;
        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
*/


