#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <set>

using namespace std;

typedef long long ll;

ifstream in("fisher.in");
ofstream out("fisher.out");

struct point {
    ll t, cnt, cost, pos;

    point(ll t, ll cnt, ll pos, ll cost = 0) : t(t), cnt(cnt), pos(pos), cost(cost) {}

    bool operator<(point b) const {
        return cost > b.cost;
    }
};

bool cmp(point a, point b) {
    if (a.pos != b.pos)
        return a.pos < b.pos;

    return a.t > b.t;
}

bool cc1(point a, point b) {
    return a.cost > b.cost;
}


void solve(int n, int m, int p) {
    vector<point> arr;

    ll pos, cnt, cost;
    for (int i = 0; i < n; ++i) {
        in >> pos >> cnt;

        arr.push_back(point(1, cnt, pos));
    }

    for (int i = 0; i < m; ++i) {
        in >> pos >> cnt >> cost;

        arr.push_back(point(-1, cnt, pos, cost));
    }


    sort(arr.begin(), arr.end(), cmp);
    multiset<point> ahg;

    ll ans = 0;
    ll cnt_fish = 0;

    ll now_pos = 0;
    for (auto x : arr) {
        now_pos = x.pos;
        if (x.t == 1) {
            cnt_fish += x.cnt;
        } else {
            ahg.insert(x);
        }

        ll cfish = cnt_fish;
        ll sums = 0;
        for (auto y : ahg) {
            if (cfish == 0)
                break;

            sums += min(cfish, y.cnt) * y.cost;
            cfish -=  min(cfish, y.cnt);
        }

        sums -= now_pos * p;
        ans = max(sums, ans);
    }

    out << ans;
}

int main() {
    ll n, m, p;
    in >> n >> m >> p;

    if (n <= 8500 && m <= 8500) {
        solve(n, m, p);
        return 0;
    }

    vector<ll> fish_pref(m + 1, 0);
    vector<ll> money_pref(m + 1, 0);
    vector<ll> cost_fish(m + 1, 0);
    vector<point> give;

    vector<point> arr;

    ll pos, cnt, cost;
    ll maxx=-1, maxy=-1, miny=1e9, minx=1e9;

    vector<point> gets;
    long long now = 1, fsh_cnt = 0;

    for (int i = 0; i < n; ++i) {
        in >> pos >> cnt;

        maxx = max(maxx, pos);
        minx = min(minx, pos);
        fsh_cnt += cnt;

        gets.push_back(point(1, cnt, pos));
        arr.push_back(point(1, cnt, pos));
    }

    for (int i = 0; i < m; ++i) {
        in >> pos >> cnt >> cost;

        maxy = max(maxy, pos);
        miny = min(miny, pos);


        give.push_back(point(-1, cnt, pos, cost));
        arr.push_back(point(-1, cnt, pos, cost));
    }



    if (p == 0) {
        sort(give.begin(), give.end(), cc1);

        ll ans = 0;
        for (int i = 0; i < m; ++i) {
            ans += min(fsh_cnt, give[i].cnt) * give[i].cost;
            fsh_cnt -= min(fsh_cnt, give[i].cnt);
        }

        out << ans;


        return 0;
    }

     if (maxy < minx) {
        sort(give.begin(), give.end(), cc1);

        now = 0;
        ll ans = 0;
        for (auto &x : give) {
            now += 1;

            cost_fish[now] = x.cost;
            money_pref[now] += money_pref[now - 1] + x.cost * x.cnt;
            fish_pref[now] += fish_pref[now - 1] + x.cnt;
        }

        sort(gets.begin(), gets.end(), cmp);
        ll now_x, cntf = 0;
        for (auto &x : gets) {
            now_x = x.pos;
            cntf += x.cnt;

            ll l = 0, r = now + 1;
            while (r - l > 1) {
                ll mid = (l + r) / 2;

                if (fish_pref[mid] <= cntf)
                    l = mid;
                else
                    r = mid;
            }

            ll sums = money_pref[l];
            if (l != now) {
                sums += (cntf - fish_pref[l]) * cost_fish[l + 1];
            }

            sums -= now_x * p;
            ans = max(sums, ans);
        }

        out << ans;

        return 0;
    }

}
