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

using namespace std;
typedef pair<int, int> ip;
typedef pair<int, ip> iip;

bool cmp(iip a, iip b) {
    return a.second.second > b.second.second;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    vector<ip> cought;
    long long sm = 0;
    for (int i = 0; i < n; i++) {
        int x, a;
        cin >> x >> a;
        sm += a;
        cought.push_back(make_pair(x, a));
    }
    vector<iip> cost;
    for (int i = 0; i < m; i++) {
        int y, b, c;
        cin >> y >> b >> c;
        cost.push_back(make_pair(y, make_pair(b, c)));
    }
    sort(cost.begin(), cost.end(), cmp);
    long long res = 0;
    long long ans = 0;
    sm = 0;
    for (int i = 0; i < n; i++) {
        sm += cost[i].second;
        ans = -(1ll * cost[i].first * p)
        int i = 0;
        while (i < m && sm > 0) {
            if (sm <= cost[i].second.first) {
                ans += 1ll * sm * cost[i].second.second;
                sm = 0;
            }
            else {
                sm -= cost[i].second.first;
                ans += 1ll * cost[i].second.first * cost[i].second.second;
            }
            i++;
            //cout << ans << " " << sm << endl;
        }
        res = max(ans, res);
    }
    cout << res << "\n";
    return 0;
}
