#include <bits/stdc++.h>
#define pii pair<long long, long long>
#define F first
#define S second

using namespace std;

struct ev{
    int x, tp;
    int w, p;

    ev(){}

    ev(int x, int tp, int w, int p): x(x), tp(tp), w(w), p(p){
    }
};

bool operator < (ev a, ev b){
    return a.x < b.x;
}

int x[500001];
long long a[500001];
int y[500001];
long long b[500001];
long long c[500001];
long long sum[2000001];
long long sum1[2000001];

void add(int pos, long long x, int l, int r, int i){
    if (l == r - 1){
        sum[i] += x;
        return;
    }
    int m = (l + r) / 2;
    if (m > pos) add(pos, x, l, m, 2 * i + 1);
    else add(pos, x, m, r, 2 * i + 2);
    sum[i] = sum[2 * i + 1] + sum[2 * i + 2];
}

void add1(int pos, long long x, int l, int r, int i){
    if (l == r - 1){
        sum1[i] += x;
        return;
    }
    int m = (l + r) / 2;
    if (m > pos) add1(pos, x, l, m, 2 * i + 1);
    else add1(pos, x, m, r, 2 * i + 2);
    sum1[i] = sum1[2 * i + 1] + sum1[2 * i + 2];
}

long long sumx(int ql, int qr, int l, int r, int i){
    if (ql >= r || l >= qr) return 0;
    if (l >= ql && qr >= r) return sum1[i];
    int m = (l + r) / 2;
    return sumx(ql, qr, l, m, 2 * i + 1) + sumx(ql, qr, m, r, 2 * i + 2);
}

pair<int, long long> lft(int l, int r, long long x, int i){
    if (l == r - 1)
        return make_pair(l, x);
    int m = (l + r) / 2;
    if (sum[2 * i + 2] <= x)
        return lft(l, m, x - sum[2 * i + 2], 2 * i + 1);
    return lft(m, r, x, 2 * i + 2);
}

vector<int> xs;

long long ct = 0;
long long dcr = 0;

long long get(){
    if (ct > sum[0]){
        return sum1[0] - dcr;
    }
    auto p = lft(0, xs.size(), ct, 0);
    long long ans = sumx(p.F + 1, xs.size(), 0, xs.size(), 0);
    if (p.F != -1){
        ans += p.S * xs[p.F];
    }
    return ans - dcr;
}

int main(){
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #else
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    long long P;
    cin >> n >> m >> P;
    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];
        xs.push_back(c[i]);
    }
    sort(xs.begin(), xs.end());
    xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
    int i = 0;
    int j = 0;
    long long ans = 0;
    while (i < n || j < m){
        if (i == n){
            dcr = P * (long long) y[j];
            int l = lower_bound(xs.begin(), xs.end(), c[j]) - xs.begin();
            add(l, b[j], 0, xs.size(), 0);
            add1(l, b[j] * c[j], 0, xs.size(), 0);
            ans = max(ans, get());
            j++;
            continue;
        }
        if (j == m){
            dcr = P * (long long) x[i];
            ct += a[i];
            ans = max(ans, get());
            i++;
            continue;
        }
        if (x[i] <= y[j]){
            dcr = P * (long long) x[i];
            ct += a[i];
            ans = max(ans, get());
            i++;
            continue;
        }
        dcr = P * (long long) y[j];
        int l = lower_bound(xs.begin(), xs.end(), c[j]) - xs.begin();
        add(l, b[j], 0, xs.size(), 0);
        add1(l, b[j] * c[j], 0, xs.size(), 0);
        ans = max(ans, get());
        j++;
    }
    cout << ans;
    return 0;
}
