#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 500050;

ll x[N], y[N], a[N];
pair < ll, ll > b[N];

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ios::sync_with_stdio(0);
    int n, m;
    ll 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].second >> b[i].first;
    if (p == 0) {
        ll cnt = 0, sum = 0;
        for (int i = 0; i < n; i++)
            cnt += a[i];
        sort(b, b + m);
        reverse(b, b + m);
        for (int i = 0; i < m; i++)
            if (cnt < b[i].second) {
                sum += cnt * b[i].first;
                break;
            }
            else {
                sum += b[i].first * b[i].second;
                cnt -= b[i].second;
            }
        cout << sum;
    }
    else
    if (y[m - 1] < x[0]) {
        ll cur_sum = 0, ma = 0;
        sort(b, b + m);
        reverse(b, b + m);
        int j = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0)
                cur_sum = -p * x[0];
            else
                cur_sum -= p * (x[i] - x[i - 1]);
            while (a[i] > 0 && j < m) {
                if (a[i] < b[j].second) {
                    cur_sum += a[i] * b[j].first;
                    b[j].second -= a[i];
                    a[i] = 0;
                    break;
                }
                else {
                    a[i] -= b[j].second;
                    cur_sum += b[j].first * b[j].second;
                    j++;
                }
            }
            ma = max(ma, cur_sum);
            //cout << i << " " << cur_sum << endl;
        }
        cout << ma << endl;
    }
    else
    if (x[n - 1] < y[0]) {
        ll cur_sum = 0, cnt = 0, ma = 0;
        int j = 0;
        for (int i = 0; i < n; i++) {
            cnt += a[i];
        }
        for (int i = 0; i < m; i++) {
            if (i == 0)
                cur_sum -= y[0] * p;
            else
                cur_sum -= (y[i] - y[i - 1]) * p;
            if (cnt < b[i].second) {
                cur_sum += cnt * b[i].first;
                cnt = 0;
            }
            else {
                cur_sum += b[i].first * b[i].second;
                cnt -= b[i].second;
            }
            ma = max(ma, cur_sum);
        }
        cout << ma << endl;

    }
    return 0;
}
