#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;

const ll N = 1e5 + 1;

struct tn2 {
    int x, a;
} ar2[N];

struct tn {
    int y, b, c;
    bool operator < (const tn x) const {
        return c > x.c;
    }
} ar[N];

bool cmp(tn a, tn b) {
    return a.c > b.c;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ll n, m, p;
    cin >> n >> m >> p;
    fr(i, n)
        cin >> ar2[i].x >> ar2[i].a;
    multiset <tn> st;
    fr(i, m) {
        cin >> ar[i].y >> ar[i].b >> ar[i].c;
        //st.insert(ar[i]);
    }

    if (p == 0) {
        sort(ar, ar + m, cmp);
        ll sum = 0;
        fr(i, n)
            sum += ar2[i].a;
        ll ans = 0;
        fr(i, m) {
            if (sum == 0)
                break;
            ll val = min(sum, (ll)ar[i].b);
            ans += val * ar[i].c;
            sum -= val;
        }
        cout << ans;
        return 0;
    }

    ll ans = 0, fish = 0;
    int curl = 0, curr = 0;

    fr(i, n + m) {
        ll pdist = 0;
        if (curr == m || (ar2[curl].x < ar[curr].y && curl < n)) {
            fish += ar2[curl].a;
            pdist = ar2[curl].x;
            curl++;
        }
        else {
            st.insert(ar[curr]);
            pdist = ar[curr].y;
            curr++;
        }
        ll sum = fish;
        ll curans = 0;
        for (multiset <tn> :: iterator it = st.begin(); it != st.end(); it++) {
            if (sum == 0)
                break;
            ll val = min(sum, (ll)(*it).b);
            curans += val * (*it).c;
            sum -= val;
        }
        if (curans > pdist * p)
            ans = max(ans, curans - pdist * p);
        //cout << i << " " << curans << " " << pdist << endl;
    }
    cout << ans;

}
