#include <bits/stdc++.h>

using namespace std;

int n, m, p;
long long x[50000], y[50000], a[50000];
pair<long long, long long> d[50000];
long long sum;

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];
    }
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> y[i] >> b >> c;
        d[i] = {c, b};
    }
    sort(d, d + m);
    long long mx = 0;
    long long prev = 0;
    int pos = m - 1;
    for (int j = 0; j < n; j++) {
        long long sum = a[j];
        long long de = x[j] * p;
        for (int i = pos; i >= 0; i--) {
            if (sum <= d[i].second) {
                de += sum * d[i].first;
                d[i].second -= sum;
                pos = i;
                break;
            }
            de += d[i].first * d[i].second;
            sum -= d[i].second;
            d[i].second = 0;
        }
        mx = max(mx, de + prev);
        de -= x[j] * p;
        prev += de;
    }
    cout << mx << "\n";
}
