#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define chr unsigned char

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);

    int n, m;
    ll p, y;
    cin >> n >> m >> p;

    ll s = 0;
    vector< pair<ll, ll> > a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());

    vector< pair<ll, ll> > b(m);
    for (int i = 0; i < m; ++i){
        cin >> y >> b[i].second >> b[i].first;
    }

    sort(b.rbegin(), b.rend());

    int k = 0;
    ll cell = 0, ans = 0;
    for (int i = 0; i < n; ++i){
        s = a[i].second;

      //  cout << cell << endl;

        while (k < m && s >= b[k].second){
            cell += b[k].first * b[k].second;
            s -= b[k].second;
            k++;
        }
        if (k < m){
            cell += b[k].first * s;
            b[k].second -= s;
        }

        ans = max(ans, cell - p * a[i].first);
    }

    cout << ans << endl;



   /* ll ans = 0;
    for (int i = 0; i < m; ++i){
        x = min(s, b[i].second);
        ans += b[i].first * x;

        s -= b[i].second;
        s = max(s, 0LL);
    } */

   // cout << ans << endl;

    fclose(stdout);
    return 0;
}
