#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

const int maxn = 2e6;

int n, m, p;

struct ev {
    bool type;
    int pos;
    int a, b, c;
    bool operator<(const ev &ot) const {
        return pos < ot.pos;
    }
};

//ev q[maxn];

int x[maxn];
int a[maxn];
int y[maxn];
int b[maxn];
int c[maxn];
pair<int, int> e[maxn];
long long q[maxn];
long long w[maxn];

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m >> p;
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> a[i];
        sum += a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> y[i] >> b[i] >> c[i];
        e[i] = {-c[i], b[i]};
    }
    sort(e, e+m);
    long long mn = 0;
    if (p == 0) {
        for (int i = 0; i < m; ++i) {
            long long k = min(sum, 1ll*e[i].second);
            mn += 1ll*(-e[i].first)*k;
            sum -= k;
        }
        cout << mn << '\n';
        return 0;
    }
    if (y[m-1] < x[0]) {
        long long ca = 0, cb = 0, ma = 0;
        for (int i = 0; i < n; ++i) {
            long long t = a[i];
            while (ca < m && e[ca].second-cb <= t) {
                ma += 1ll*(-e[ca].first)*(e[ca].second-cb);
                t -= e[ca].second-cb;
                cb = 0;
                ++ca;
            }
            if (ca < m) {
                ma += 1ll*(-e[ca].first)*t;
                cb += t;
                t = 0;
            }
            mn = max(mn, ma-1ll*x[i]*p);
        }
        cout << mn << '\n';
    } else {
        int ma = 0;
        long long mo = 0;
        for (int i = 0; i < m; ++i) {
            ma = max(ma, e[i].second);
            int k = min(sum, 1ll*(-e[i].first));
            sum -= k;
            mo += 1ll*(-e[i].first)*k;
            mn = max(mn, mo-1ll*ma*p);
        }
        cout << mn << '\n';
    }
     /*for (int i = 0; i < n; ++i) {
        int x, a;
        cin >> x >> a;
        q[i] = {0, x, a, 0, 0};
    }
    for (int i = 0; i < m; ++i) {
        int y, b, c;
        cin >> y >> b >> c;
        q[n+i] = {0, y, 0, b, c};
    }
    int u = n+m;
    sort(q, q+u);
    int cm = 0, ce = 0, cp = 0, cr = 0;
    multiset<pair<int, int>> s;
    long long mx = 0;
    for (int i = 0; i < u; ++i) {
        ev& e = q[i];
        if (e.type) {

        } else {
            cm += e.a;
        }
        mx = max(mx, 1ll*cp-1ll*e.pos*p);
    }
    cout << mx << '\n';*/

    return 0;
}
