#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cassert>

using namespace std;

typedef long long ll;

const int MAXN = 5e5;
const int INF = 2e9;

int n, m, p;

ll d1[4 * MAXN];
void init1() {
    for (int i = 0; i < 4 * MAXN; i++)
        d1[i] = 0;
}
ll get1(int i, int l, int r, int ql, int qr) {
    if (l > r || l > qr || ql > r || ql > qr)
        return 0;
    if (ql <= l && r <= qr)
        return d1[i];
    int m = (l + r) / 2;
    return get1(2 * i, l, m, ql, qr) + get1(2 * i + 1, m + 1, r, ql, qr);
}
ll get1(int ql, int qr) { return get1(1, 0, MAXN - 1, ql, qr); }
void update1(int i, int l, int r, int pos, ll f) {
    if (l > pos || r < pos)
        return;
    if (l == r) {
        d1[i] += f;
        return;
    }
    int m = (l + r) / 2;
    update1(2 * i, l, m , pos, f);
    update1(2 * i + 1, m + 1, r, pos, f);
    d1[i] = d1[2 * i] + d1[2 * i + 1];
}
void update1(int pos, ll f) { update1(1, 0, MAXN - 1, pos, f); }

ll d2[4 * MAXN];
void init2() {
    for (int i = 0; i < 4 * MAXN; i++)
        d2[i] = 0;
}
ll get2(int i, int l, int r, int ql, int qr) {
    if (l > r || l > qr || ql > r || ql > qr)
        return 0;
    if (ql <= l && r <= qr)
        return d2[i];
    int m = (l + r) / 2;
    return get2(2 * i, l, m, ql, qr) + get2(2 * i + 1, m + 1, r, ql, qr);
}
ll get2(int ql, int qr) { return get2(1, 0, MAXN - 1, ql, qr); }
void update2(int i, int l, int r, int pos, ll f) {
    if (l > pos || r < pos)
        return;
    if (l == r) {
        d2[i] += f;
        return;
    }
    int m = (l + r) / 2;
    update2(2 * i, l, m , pos, f);
    update2(2 * i + 1, m + 1, r, pos, f);
    d2[i] = d2[2 * i] + d2[2 * i + 1];
}
void update2(int pos, ll f) { update2(1, 0, MAXN - 1, pos, f); }

struct El {
    int x, w, c, num;
    bool type;
};
bool operator <(El a, El b) { return make_pair(a.x, a.num) < make_pair(b.x, b.num); }
vector <El> v;
vector <pair <int, int> > k;
int pos[MAXN];

ll cnt = 0;

void resize_(ll all, int x) {
    int left = -1, right = m - 1;
    while (right - left > 1) {
        int middle = (left + right + 1) / 2;
        if (get2(0, middle) < all)
            left = middle;
        else
            right = middle;
    }
    cnt = get1(0, right);
    if (get2(0, right) > all) {
        ll c = get1(right, right) / get2(right, right);
        cnt -= c * (get2(0, right) - all);
    }
    cnt -= (ll)x * (ll)p;
}

int main() {
    assert(freopen("fisher.in", "r", stdin));
    assert(freopen("fisher.out", "w", stdout));

    scanf("%d%d%d", &n, &m, &p);
    for (int i = 0; i < n; i++) {
        int x, a; scanf("%d%d", &x, &a);
        v.push_back({x, a, -1, i, true});
    }

    for (int i = 0; i < m; i++) {
        int y, b, c; scanf("%d%d%d", &y, &b, &c);
        v.push_back({y, b, c, i, false});
        k.push_back({-c, i});
    }

    init1(); init2();

    sort(k.begin(), k.end());
    for (int i = 0; i < int(k.size()); i++)
        pos[k[i].second] = i;

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

    ll ans = 0, all = 0;
    for (int i = 0; i < int(v.size()); i++) {
        if (v[i].type)
            all += v[i].w;
        else if (!v[i].type) {
            update1(pos[v[i].num], (ll)v[i].w * (ll)v[i].c);
            update2(pos[v[i].num], (ll)v[i].w);
        }
        resize_(all, v[i].x);
        ans = max(ans, cnt);
    }

    printf("%lld\n", ans);

    return 0;
}
