#include <bits/stdc++.h>

using namespace std;

long long n, m, p;
long long x[50000], y[50000], a[50000], b[500000], c[50000];
vector<long long> check;

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;
        sum -= itr->second;
        s.erase(itr);
    }
    return ans + p * M;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    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];
        check.push_back(x[i]);
    }
    for (int i = 0; i < m; i++) {
        cin >> y[i] >> b[i] >> c[i];
        check.push_back(y[i]);
    }
    long long mx = 0;
    for (int i = 0; i < check.size(); i++) {
        mx = max(mx, f(check[i]));
    }
    cout << mx << "\n";
}

