#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define MAXN 60000
#define ll long long
using namespace std;

struct baza
{
    ll y, b, c, id;
    baza(ll _y, ll _b, ll _c)
    {
        y = _y;
        b = _b;
        c = _c;
    }
    baza()
    {
        *this = baza(0, 0, 0);
    }
    friend int operator<(baza l, baza r)
    {
        if (l.c == r.c)
        {
            return l.id < r.id;
        }
        return l.c > r.c;
    }
}ar[MAXN];

ll x[MAXN], n, m, p, sum, a[MAXN], cr[MAXN * 2], nc;

bool cmp(baza l, baza r)
{
    if (l.c == r.c)
    {
        return l.id < r.id;
    }
    return l.c > r.c;
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i] >> a[i];
        sum += a[i];
        cr[nc++] = x[i];
    }
    x[n] = 1e10;
    for (ll i = 0; i < m; i++)
    {
        cin >> ar[i].y >> ar[i].b >> ar[i].c;
        cr[nc++] = ar[i].y;
        ar[i].id = i;
    }
    sort(cr, cr + nc);
    nc = unique(cr, cr + nc) - cr;
    ar[m] = baza(1e10, 0, 0);
    if (p == 0)
    {
        sort(ar, ar + m, cmp);
        ll res = 0, cur = sum;
        for (int i = 0; i < m; i++)
        {
            if (cur > 0)
            {
                res += ar[i].c * (min(cur, ar[i].b));
                cur -= ar[i].b;
            }
            else
                break;

        }
        cerr << res << '\n';
        cout << res << '\n';
        return 0;
    }
    if (ar[m - 1].y < x[0])
    {
int i = 0, j = 0, c = 0;
    ll res = 0, sum = 0, fish = 0;
    set<baza> cur;
    for(;;)
    {
        if (x[i] <= ar[j].y)
        {
            sum -= (x[i] - c) * p;
            fish += a[i];
            c = x[i];
            i++;
        }
        else
        {
            sum -= (ar[j].y - c) * p;
            c = ar[j].y;
            cur.insert(ar[j]);
            j++;
        }
        while(fish > 0 && !cur.empty())
        {
            baza b = *cur.begin();
            cur.erase(cur.begin());
            ll sol = min(fish, b.b);
            b.b -= sol;
            fish -= sol;
            sum += sol * b.c;
            if (b.b > 0)
                cur.insert(b);
        }
        res = max(res, sum);
        if (i >= n && j >= m)
            break;
    }
    cout << res << '\n';
    cerr << res << '\n';
    return 0;
    }

    cerr << "full\n";
    int i = 0, j = 0, c = 0;
    ll bres = 0, sum = 0, fish = 0;
    set<baza> cur;
    for(;;)
    {
        if (x[i] <= ar[j].y)
        {
            sum -= (x[i] - c) * p;
            fish += a[i];
            c = x[i];
            i++;
        }
        else
        {
            sum -= (ar[j].y - c) * p;
            c = ar[j].y;
            cur.insert(ar[j]);
            j++;
        }
        ll res = 0;
        ll sum = fish;
        for (auto p : cur)
        {
            if (sum > 0)
            {
                res += p.c * (min(sum, p.b));
                sum -= p.b;
            }
            else
                break;
        }
        //cerr << c << ' ' << res << '\n';
        bres = max(res - c * p, bres);
        if (i >= n && j >= m)
            break;
    }
//    for (int i = 0; i < nc; i++)
//    {
//        c = cr[i];
//        sum = 0;
//        for (int i = 0; i < n; i++)
//            if (x[i] <= c)
//                sum += a[i];
//        set<baza> w;
//        for (int i = 0; i < m; i++)
//            if (ar[i].y <= c)
//                w.insert(ar[i]);
//        ll res = 0;
//        ll cur = sum;
//        for (auto i : w)
//        {
//            if (cur > 0)
//            {
//                res += i.c * (min(cur, i.b));
//                cur -= i.b;
//            }
//            else
//                break;
//        }
//        cerr << c << ' ' << res << '\n';
//        bres = max(res - c * p, bres);
//    }
    cout << bres << '\n';
    cerr << bres << '\n';
    return 0;
}
