#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
#define INF INT_MAX
#define NAME "fisher"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);

using namespace std;

const int N = 50001;

struct t {
    ll x, b, c;
} a[N], b[N], c[N], d[N];

bool cmp(t i, t j) {
    return i.c > j.c;
}

bool comp(t i, t j) {
    return i.x < j.x;
}

int n, m, p, i, uk;
ll sum, ans, sum1, tans;

set <t> S;
set <t> :: iterator it;

inline bool operator < (t i, t j) {
    return i.c > j.c;
}

inline ll mn(ll a, ll b) {
    if (a < b)
        return a;
    else
        return b;
}

int main()
{
    FREOPEN
    ios_base::sync_with_stdio(0);
    cin >> n >> m >> p;
    for (i = 0; i < n; i++) {
        cin >> a[i].x >> a[i].b;
        a[i].c = -1;
        c[i] = a[i];
        sum += a[i].b;
    }
    for (i = 0; i < m; i++) {
        cin >> b[i].x >> b[i].b >> b[i].c;
        c[n + i] = b[i];
    }
    if (p == 0) {
        sort(b, b + m, cmp);
        for (i = 0; i < m; i++) {
            ans += mn(sum, 1ll * b[i].b) * b[i].c;
            sum -= mn(sum, 1ll * b[i].b);
        }
        return cout << ans, 0;
    }
    if (n <= 8500 && m <= 8500) {
        sort(c, c + n + m, comp);
        sum = ans = 0;
        for (i = 0; i < n + m; i++) {
            if (c[i].c != -1)
                S.insert(c[i]);
            else
                sum += c[i].b;
            sum1 = sum;
            tans = 0;
            for (it = S.begin(); it != S.end(); it++) {
                tans += mn(sum1, 1ll * it->b) * it->c;
                sum1 -= mn(sum1, 1ll * it->b);
            }
            ans = max(ans, tans - 1ll * p * c[i].x);
        }
        return cout << ans, 0;
    }
    sort(a, a + n, comp);
    sort(b, b + m, cmp);
    uk = sum = 0;
    for (i = 0; i < n; i++) {
        sum += a[i].b;
        while (uk < m || !sum) {
            if (b[uk].b <= sum) {
                tans += b[uk].b * b[uk].c;
                sum -= b[uk].b;
                uk++;
            } else {
                tans += sum * b[uk].c;
                b[uk].b -= sum;
                sum = 0;
            }
        }
        ans = max(ans, tans - a[i].x * p);
    }
    cout << ans << endl;
    return 0;
}








