#include <bits/stdc++.h>

#define vec vector
#define forn(i, n) for (int i = 0; i < n; i++)
#define mp make_pair
#define YY second
#define XX first
#define vec vector
#define str string
#define pb push_back
#define ll long long
#define all(a) a.begin(), a.end()

using namespace std;

const bool is_testing = false;

ll n, m, p;
vec< pair<ll, ll> > a;
vec< pair< pair<ll, ll>, ll> > b;

struct place
{
    ll x, cost, kol, type;
    place()
    {
        x = 0;
        cost = 0;
        kol = 0;
    }
    place(ll x1, ll cost1, ll kol1, ll type1)
    {
        x = x1;
        cost = cost1;
        kol = kol1;
        type = type1;
    }
};

vec<place> q;

bool cmp(place a, place b)
{
    int x1 = a.x;
    int x2 = b.x;
    int type1 = a.type;
    int type2 = b.type;
    return (x1 < x2 || x1 == x2 && type1 < type2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    if (is_testing)
    {
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    }
    cin >> n >> m >> p;
    a.resize(n);
    b.resize(m);
    forn(i, n)
        cin >> a[i].YY >> a[i].XX;
    forn(i, m)
        cin >> b[i].YY >> b[i].XX.YY >> b[i].XX.XX;
    forn(i, n)
        q.pb(place(a[i].YY, 0, a[i].XX, 1));

    forn(i, m)
        q.pb(place(b[i].YY, b[i].XX.XX, b[i].XX.YY, 2));
    sort(all(q), cmp);
    //forn(i, q.size())
    //    cout << q[i].x << ' ' << q[i].type << endl;
    ll ans = 0, ryb = 0, sum = 0;
    multiset< pair<ll, ll> > se;
    forn(i, q.size())
    {
        if (q[i].type == 1)
        {
            ryb += q[i].kol;
        }
        else
        {
            if (ryb >= q[i].kol)
            {
                ryb -= q[i].kol;
                sum += q[i].kol * q[i].cost;
                ans = max(ans, sum - p * q[i].x);
                se.insert(mp(q[i].cost, q[i].kol));
            }
            else
            {
                sum += ryb * q[i].cost;
                ans = max(ans, sum - p * q[i].x);
                ll d = q[i].kol - ryb;
                ryb = 0;
                while(true)
                {
                    if (se.size() == 0)
                        break;
                    pair<ll, ll> t = *se.begin();
                    if (t.XX >= q[i].cost)
                        break;
                    se.erase(se.find(t));
                    if (t.YY <= d)
                    {
                        d -= t.YY;
                        sum -= t.YY * t.XX;
                        sum += t.YY * q[i].cost;
                        ans = max(ans, sum - p * q[i].x);
                    }
                    else
                    {
                        sum -= d * t.YY;
                        sum += d * q[i].cost;
                        ans = max(ans, sum - p * q[i].x);
                        t.YY -= d;
                        se.insert(t);
                        d = 0;
                        break;
                    }
                }
                se.insert(mp(q[i].cost, q[i].kol - d));
            }
        }
    }
    cout << ans;
}
