#include <bits/stdc++.h>
#define pb push_back
#define mkp make_pair
#define mt make_tuple
#define ins insert
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> tt;


const int N = 2 * 500000 + 5;
const int SQR = sqrt(N) + 1;
int realSQR;

/*ll treeCount[4*N];
ll treeAns[4*N];

ll getCount(int v, int L, int R, int l, int r) {
    if (L > r || l > R)
        return 0;
    if (l >= L && r <= R)
        return treeCount[v];
    return getCount(v * 2, L, R, l, (l + r) / 2) +
            getCount(v * 2 + 1, L, R, (l + r) / 2 + 1, r);
}

void addCount(int v, int l, int r, int pos, ll add) {
    if (l == r) {
        treeCount[v] += add;
    } else {
        if (pos <= (l + r) / 2)
            addCount(v * 2, l, (l + r) / 2, pos, add);
        else
            addCount(v * 2 + 1, (l + r) / 2 + 1, r, pos, add);
        treeCount[v] = treeCount[v * 2] + treeCount[v * 2 + 1];
    }
}

ll getAns(int v, int L, int R, int l, int r) {
    if (L > r || l > R)
        return 0;
    if (l >= L && r <= R)
        return treeAns[v];
    return getAns(v * 2, L, R, l, (l + r) / 2) +
            getAns(v * 2 + 1, L, R, (l + r) / 2 + 1, r);
}

void addAns(int v, int l, int r, int pos, ll add) {
    if (l == r) {
        treeAns[v] += add;
    } else {
        if (pos <= (l + r) / 2)
            addAns(v * 2, l, (l + r) / 2, pos, add);
        else
            addAns(v * 2 + 1, (l + r) / 2 + 1, r, pos, add);
        treeAns[v] = treeAns[v * 2] + treeAns[v * 2 + 1];
    }
}*/

ll sqCont[SQR];
ll cont[N];
ll sqAnk[SQR];
ll ank[N];

ll prodY[N];
ll prodB[N];
ll prodC[N];
ll fishX[N];
ll fishA[N];

int n, m;
ll mnosh[N];
ll counter[N];
ll p;
int allsSz;
ll currFish = 0;
ll minusDist = 0;

ll findAnswer() {
    ll kolvo = currFish;
    ll mini;
    ll ans = 0;

    bool can = true;
    for (int i = 0; i < allsSz;) {
        if (can) {
            if (sqCont[i / realSQR] <= kolvo) {
                kolvo -= sqCont[i / realSQR];
                ans += sqAnk[i / realSQR];
                i += realSQR;
            } else {
                can = false;
            }
        } else {
            if (cont[i] <= kolvo) {
                kolvo -= cont[i];
                ans += ank[i];
                i++;
            } else {
                ll mini = min(kolvo, cont[i]);
                kolvo -= mini;
                ans += mini * mnosh[i];
                break;
            }
        }
    }

    return ans -= minusDist;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);

    fill(counter, counter + N, 0);

    scanf("%d%d%lld", &n, &m, &p);
    vector<tt> sobs;
    set<ll> alls;
    map<ll, int> index;

    for (int i = 0; i < n; i++) {
        ll x, a;
        scanf("%lld%lld", &x, &a);
        fishX[i] = x;
        fishA[i] = a;
        sobs.pb(mt(x, i, 0));   // FISH
    }

    for (int i = 0; i < m; i++) {
        ll y, b, c;
        scanf("%lld%lld%lld", &y, &b, &c);
        alls.ins(c);
        prodY[i] = y;
        prodB[i] = b;
        prodC[i] = c;
        sobs.pb(mt(y, i, 1));   // PROD
    }

    int cnt = alls.size() - 1;
    allsSz = cnt + 1;
    for (auto it : alls) {
        mnosh[cnt] = it;
        index[it] = cnt;
        cnt--;
    }

    realSQR = sqrt(allsSz) + 2;

    for (int i = 0; i < m; i++) {
        prodC[i] = index[prodC[i]];
    }

    sort(sobs.begin(), sobs.end());

    ll maxi = 0;

    for (int i = 0; i < n + m; i++) {
        int type = get<2>(sobs[i]);
        int num = get<1>(sobs[i]);
        if (type == 0) {
            // FISH
            ll x, a;
            x = fishX[num];
            a = fishA[num];
            currFish += a;
            minusDist = x * p;
        } else {
            ll y, b, c;
            y = prodY[num];
            b = prodB[num];
            c = prodC[num];

            cont[c] += b;
            sqCont[c / SQR] += b;
            ank[c] += b * mnosh[c];
            sqAnk[c / SQR] += b * mnosh[c];

            minusDist = y * p;
        }

        maxi = max(maxi, findAnswer());
    }

    printf("%lld", maxi);
}