#include <bits/stdc++.h>

using namespace std;

#define int long long

struct Node {
    int ans;
    int sumb;
};

const int tsize = 1 << 19;
const int maxn = tsize;
Node tree[tsize * 2];

void add(int p, int b, int c) {
    p += tsize;
    while (p > 0) {
        tree[p].ans += b * c;
        tree[p].sumb += b;
        p >>= 1;
    }
}

int get(int sum) {
    int v = 1;
    int ans = 0;
    while (v < tsize) {
        if (tree[v * 2].sumb > sum) {
            v = v * 2;
        } else {
            sum -= tree[v * 2].sumb;
            ans += tree[v * 2].ans;
            v = v * 2 + 1;
        }
    }
    if (tree[v].sumb != 0) {
        int c = tree[v].ans / tree[v].sumb;
        ans += min(sum * c, tree[v].ans);
    }
    return ans;
}

int n, m, p;
int x[maxn];
int a[maxn];
int y[maxn];
int b[maxn];
int c[maxn];

int order[maxn];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);

    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];
    }

    vector< pair<int, int> > tmp(m);
    for (int i = 0; i < m; i++) {
        tmp[i] = {c[i], i};
    }
    sort(tmp.rbegin(), tmp.rend());
    for (int i = 0; i < m; i++) {
        order[tmp[i].second] = i;
    }

    int px = 0, py = 0;
    int ans = 0;
    int sum = 0;
    while (px < n || py < m) {
        if (px < n && (py == m || x[px] < y[py])) {
            sum += a[px];
            ans = max(ans, -p * x[px] + get(sum));
            px++;
        } else {
            add(order[py], b[py], c[py]);
            ans = max(ans, -p * y[py] + get(sum));
            py++;
        }
    }

    cout << ans << '\n';
}

