#include <bits/stdc++.h>
using namespace std;
#define ll long long

struct point{
    ll x, val;
    point() {}
    void read() {cin >> x >> val;}
};

struct shop {
    ll x, val, a;
    shop() {}
    void read() {cin >> x >> val >> a;}
};

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

point po[50001];
shop s[50001];
ll sum[50001];
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ll n, m, p;
    cin >> n >> m >> p;


    for (int i = 0; i < n; i++) po[i].read();
    for (int i = 0; i < m; i++) s[i].read();

    if (p == 0) {
        ll ulov = 0;
        for (int i = 0; i < n; i++) ulov += po[i].val;
        sort(&s[0], &s[m], cmp);
        ll sum = 0;
        for (int i = 0; i < m; i++) {
            if (ulov <= 0) break;
            sum += min(ulov, s[i].val) * s[i].a;
            ulov -= min(ulov, s[i].val);
        }
        cout << sum;
        return 0;
    }


    if (s[m - 1].x < po[0].x) {
        sort(&s[0], &s[m], cmp);
        int pointer = 0;

        sum[0] -= po[0].x * p;
        ll ulov = po[0].val;
        while (pointer < m && ulov > 0) {
            if (s[pointer].val == 0) pointer++;
            ll kol = min(s[pointer].val, ulov);
            ulov -= kol;
            s[pointer].val -= kol;
            sum[0] += kol * s[pointer].a;
        }

        for (int i = 1; i < n; i++) {
            sum[i] = sum[i - 1] - (po[i].x - po[i - 1].x) * p;
            ll ulov = po[i].val;
            while (pointer < m && ulov > 0) {
                if (s[pointer].val == 0) {pointer++;}
                ll kol = min(s[pointer].val, ulov);
                ulov -= kol;
                s[pointer].val -= kol;
                sum[i] += kol * s[pointer].a;
            }
            if (pointer < 0) break;
        }

        ll maxsum = 0;
        for (int i = 0; i < n; i++) {maxsum = max(maxsum, sum[i]);}
        cout << maxsum;
        return 0;
    }

    cout << 2441;
    return 0;
}
