#include<bits/stdc++.h>

using namespace std;

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    long long n, m, p;
    cin >> n >> m >> p;
    long long x[n];
    long long a[n];
    long long y[m];
    long long b[m];
    long long c[m];
   // vector<pair<long long, long long>> a(n + m);
    for (long long i = 0; i < n; i++)
    {
        cin >> x[i] >> a[i];
       // a.push_back(make_pair(x[i], 0));
    }
    for (long long i = 0; i < m; i++)
    {
        cin >> y[i] >> b[i] >> c[i];
    }
    if (p == 0)
    {
        long long s = 0;
        for (long long i = 0; i < n; i++)
        {
            s += a[i];
        }
        //cout << s;
        vector<pair<long long, long long>> ys;
        for (long long i = 0; i < m; i++)
        {
            ys.push_back(make_pair(c[i], b[i]));
        }
        sort(ys.rbegin(), ys.rend());
        long long now_s = 0;
        long long ans = 0;
        for (long long i = 0; i < m; i++)
        {
            if (now_s + ys[i].second >= s)
            {
                ans += (s - now_s) * ys[i].first;
                break;
            }
            else
            {
                now_s += ys[i].second;
                ans += ys[i].first * ys[i].second;
            }
        }
        cout << ans;
    }
    else if (y[m - 1] < x[0])
    {
        vector<pair<long long, long long>> ys;
        for (long long i = 0; i < m; i++)
        {
            ys.push_back(make_pair(c[i], b[i]));
        }
        sort(ys.rbegin(), ys.rend());
        int imr = 0;
        long long int rl = 0;
        long long now_s;
        long long s;
        s = 0;
        int ansans = 0;
        for (int j = 0; j < n; j++)
        {
            int ans = 0;
            now_s = s;
            s += a[j];
            for (long long i = imr; i < m; i++)
            {
                if (i == imr)
                {
                    ys[i].second -= rl;
                    if (now_s + ys[i].second >= s)
                    {
                        ans += (s - now_s) * ys[i].first;
                        ys[i].second += rl;
                        rl += s - now_s;
                        break;
                    }
                    else
                    {
                        now_s += ys[i].second;
                        ans += ys[i].first * ys[i].second;
                    }
                    ys[i].second += rl;
                    continue;
                }
                if (now_s + ys[i].second >= s)
                {
                    ans += (s - now_s) * ys[i].first;
                    imr = i;
                    rl = s - now_s;
                    break;
                }
                else
                {
                    now_s += ys[i].second;
                    ans += ys[i].first * ys[i].second;
                }
            }
            ansans = max(ansans, ans - p * x[j]);
        }
        cout << ansans;
    }
}
