#include <bits/stdc++.h>

using namespace std;

const double EPS = 1e-9;

long long n, m, p;
long long x[50000], y[50000], a[50000], b[500000], c[50000];
long long sum;

long long f(long long M) {
    long long sum = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] <= M) {
            sum += a[i];
        }
    }
    set<pair<long long, long long> > s;
    for (int i = 0; i < m; i++) {
        if (y[i] <= M) {
            s.insert({c[i], b[i]});
        }
    }
    while (sum > 0 && s.size() > 0) {
        auto itr = s.end();
        itr--;
        if (sum <= itr->second) {
            ans += sum * itr->first;
            break;
        }
        ans += itr->first * itr->second;
        s.erase(itr);
        sum -= itr->second;
    }
    return ans + p * M;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    srand(1234567);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> p;
    p *= -1;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i] >> b[i] >> c[i];
    }
    long long cur = (rand() << 15) + rand();
    double t = 1000;
    double r = 1e9;
    while (t > EPS && r > 1 + EPS) {
        long long d = ((rand() << 15) + rand()) % (int) r;
        d -= (int) (r / 2);
        if (cur + d < 0) {
            d = -cur;
        }
        int M = cur + d;
        if (f(M) > f(cur)) {
            cur = M;
        } else {
            double r = rand() % RAND_MAX;
            if (r < exp(-t * (f(cur) - f(M)))) {
                cur = M;
            }
        }
        t *= 0.99;
        r *= 0.99;
    }
    cout << f(cur) << "\n";
}
