#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
#define inf (int) 1e9 + 7

struct mag{
    int y;
    ll t, c;
};

vector< pair<ll, ll> > a;
vector<mag> b;
int n, m;
ll p;
const int C = 1000;


bool cmp(mag a, mag b){
    return a.y < b.y;
}


ll f(int x){
    ll s = 0;
    vector< pair<ll, ll> > z;

    for (int j = 0; j < n; ++j)
        if (a[j].first <= x)
            s += a[j].second;
        else
            break;

    for (int j = 0; j < m; ++j)
        if (b[j].y <= x)
            z.pb(mp(b[j].c, b[j].t));
        else
            break;

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

    int k = (int) z.size();

        //    for (int j = 0; j < k; ++j)
         //       cout << x[i] << ' '<< s << ' ' << z[j].first << ' ' << z[j].second << endl;

    ll cell = 0, g;
    for (int j = 0; j < k; ++j){
        g = min(s, z[j].second);
        cell += g * z[j].first;

        s -= z[j].second;
        s = max(s, 0LL);
        if (s == 0)
            break;
    }

    return cell - p * x;
}


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

    cin >> n >> m >> p;

    a.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i].first >> a[i].second;

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

    if (n <= 8500 && m <= 8500){
        vector<ll> x(n + m);

        for (int i = 0; i < n; ++i)
            x[i] = a[i].first;

        b.resize(m);
        for (int i = 0; i < m; ++i){
            cin >> b[i].y >> b[i].t >> b[i].c;
            x[n + i] = b[i].y;
        }

        sort(b.begin(), b.end(), cmp);
        sort(x.begin(), x.end());

       int l = 0, r = n + m - 1, m1, m2;
        while (r - l >= 3){
            m1 = l + (r - l) / 3;
            m2 = r - (r - l) / 3;

            if (f(x[m1]) > f(x[m2]))
                r = m2;
            else
                l = m1;
        }

        ll ans = 0;
        for (int i = l - C; i <= l + C; ++i)
            if (i >= 0 && i < n + m)
                ans = max(ans, f(x[i]));

        cout << ans << endl;
        fclose(stdout);
        return 0;
    }

    int y;
    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;
    ll s = 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;
}
