#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; ++i)
#define frab(i, a, b) for (int i = a; i < b; ++i)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;

const ll N = 1e5 + 1;

struct tn2 {
    int x, a;
} ar2[N];

struct tn {
    int y, b, c, used, num;
    bool operator < (const tn x) const {
        if (b == 0)
            return false;
        if (x.b == 0)
            return true;
        return c > x.c;
    }
} ar[N];

bool cmp(tn a, tn b) {
    return a.c > b.c;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    fr(i, n)
        cin >> ar2[i].x >> ar2[i].a;
    multiset <tn> st;
    fr(i, m) {
        cin >> ar[i].y >> ar[i].b >> ar[i].c;
        ar[i].num = i;
        //st.insert(ar[i]);
    }

    if (p == 0) {
        sort(ar, ar + m, cmp);
        ll sum = 0;
        fr(i, n)
            sum += ar2[i].a;
        ll ans = 0;
        fr(i, m) {
            if (sum == 0)
                break;
            ll val = min(sum, (ll)ar[i].b);
            ans += val * ar[i].c;
            sum -= val;
        }
        cout << ans;
        return 0;
    }

    if (ar2[0].x > ar[m - 1].y) {
        fr(i, m)
            st.insert(ar[i]);
        ll ans = 0;
        ll curans = 0;
        ll fish = 0;
        fr(i, n) {
            fish += ar2[i].a;
            while (fish > 0 && st.size()) {
                tn tmp = *st.begin();
                st.erase(st.begin());
                ll val = min(fish, (ll)tmp.b);
                curans += val * (ll)tmp.c;
                fish -= val;
                tmp.b -= val;
                if (tmp.b != 0)
                    st.insert(tmp);
            }
            ans = max(ans, curans - (ll)ar2[i].x * (ll)p);
        }
        cout << ans;
        return 0;
    }

    if (ar2[n - 1].x < ar[0].y) {
        //map <int, int> usd;
        ll sum = 0;
        fr(i, n)
            sum += ar2[i].a;
        fr(i, m)
            st.insert(ar[i]);

        ll ans = 0, curans = 0;

        while (sum && st.size()) {
            tn tmp = *st.begin();
            if (tmp.b <= 0)
                break;
            st.erase(st.begin());
            ll val = min(sum, (ll)tmp.b);
            curans += (ll)val * (ll)tmp.c;
            tmp.b -= val, tmp.used += val;
            sum -= val;
            //usd[-y] += val;
            ar[tmp.num].b -= val;
            ar[tmp.num].used += val;
            st.insert(tmp);
            //curans += val * tmp.c;
        }
        //cout << p << " " << ar[m - 1].y << endl;
        ans = max(ans, curans - (ll)ar[m - 1].y * (ll)p);
        for (int i = m - 2; i >= 0; i--) {
            sum += ar[i + 1].used;
            curans -= (ll)ar[i + 1].used * (ll)ar[i + 1].c;
            tn tmp = ar[i + 1];
            assert(st.count(tmp));
//            if (!st.count(tmp)) {
//                cout << "0" << endl;
//                return 0;
//            }
            st.erase(st.find(tmp));

            while (sum && st.size()) {
                tn tmp = *st.begin();
                if (tmp.b <= 0)
                    break;
                st.erase(st.begin());
                int val = min(sum, (ll)tmp.b);
                //ans += val * tmp.c;
                tmp.b -= val, tmp.used += val;
                sum -= val;
                //usd[-y] += val;
                ar[tmp.num].b -= val;
                ar[tmp.num].used += val;
                curans += (ll)val * (ll)tmp.c;
                st.insert(tmp);
            }
            ans = max(ans, curans - (ll)ar[i].y * (ll)p);
        }
        cout << ans;
        return 0;
    }

    ll ans = 0, fish = 0;
    int curl = 0, curr = 0;

    fr(i, n + m) {
        ll pdist = 0;
        if (curr == m || (ar2[curl].x < ar[curr].y && curl < n)) {
            fish += ar2[curl].a;
            pdist = ar2[curl].x;
            curl++;
        }
        else {
            st.insert(ar[curr]);
            pdist = ar[curr].y;
            curr++;
        }
        ll sum = fish;
        ll curans = 0;
        for (multiset <tn> :: iterator it = st.begin(); sum > 0 && it != st.end(); ++it) {
            int val = min(sum, (ll)(*it).b);
            curans += (ll)val * (*it).c;
            sum -= val;
        }
        if (curans > pdist * p)
            ans = max(ans, curans - pdist * p);
        //cout << i << " " << curans << " " << pdist << endl;
        if ((double)clock() / (double)CLOCKS_PER_SEC > 0.96)
            break;
    }
    cout << ans;

}
