#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

const int MAX_N = 500001;

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

int main()
{
    #define fname "fisher"
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    cin.sync_with_stdio(0);
    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];
    if (p == 0)
    {
        long long to = 0;
        for (int i = 0; i < n; i++)
            to += a[i];
        vector<pair<long long, long long> > v;
        for (int i = 0; i < m; i++)
            v.push_back(make_pair(c[i], b[i]));
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        long long ans = 0;
        for (pair<long long, long long > t : v)
        {
            if (to == 0)
                break;
            if (t.second > to)
            {
                ans += to * t.first;
                break;
            }
            to -= t.second;
            ans += t.first * t.second;
        }
        cout << ans;
        return 0;
    }
    if (y[m - 1] < x[0])
    {
        vector<pair<long long, long long> > v;
        for (int i = 0; i < m; i++)
            v.push_back(make_pair(c[i], b[i]));
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        long long ans = 0;
        long long pol = 0;
        int now = 0;
        for (int i = 0; i < n; i++)
        {
            bool br = false;
            int f = now;
            for (int j = f; j < m; j++)
            {
                if (a[i] == 0)
                {
                    now = j;
                    br = true;
                    break;
                }
                if (v[j].second > a[i])
                {
                    v[j].second -= a[i];
                    pol += v[j].first * a[i];
                    now = j;
                    br = true;
                    break;
                }
                a[i] -= v[j].second;
                pol += v[j].first * v[j].second;
            }
            if (!br)
                now = m;
            ans = max(ans, pol - p * x[i]);
        }
        cout << ans;
        return 0;
    }
    return 0;
}
