#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)

const int LEN = 500500;

struct fish
{
    ll x, cnt;
};

struct mag
{
    ll x, c, cnt, id;
};

bool comp(const mag &a, const mag &b)
{
    return (a.c > b.c);
}

bool comp2(const mag &a, const mag &b)
{
    return (a.x < b.x);
}

bool comp1(const fish &a, const fish &b)
{
    return (a.x < b.x);
}

bool operator < (const mag &a, const mag &b)
{
    return (a.c > b.c || (a.c == b.c && (a.cnt > b.cnt || (a.cnt == b.cnt && a.id > b.id))));
}

ll n, m, p, res, kol, res1, mx, j, kol1, mx1, mn, pos[LEN], use[LEN];
fish ar[LEN];
mag ar1[LEN], ar2[LEN];


set <mag> q;

ll get(ll kol)
{
    ll res = 0;
    ll kol1;

    set <mag>::iterator it = q.begin();

    while (kol > 0 && it != q.end())
    {
        kol1 = min(kol, it->cnt);
        res += it->c * kol1;
        kol -= kol1;
        it++;
    }

    return res;
}

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

    cin >> n >> m >> p;
    for (int i = 0; i < n; i++)
    {
        //cin >> ar[i].x >> ar[i].cnt;
        scanf("%I64d %I64d", &ar[i].x, &ar[i].cnt);
        kol += ar[i].cnt;
        mx1 = max(mx1, ar[i].cnt);
    }

    mn = 10000000000;
    for (int i = 0; i < m; i++)
    {
        //cin >> ar1[i].x >> ar1[i].cnt >> ar1[i].c;
        scanf("%I64d %I64d %I64d", &ar1[i].x, &ar1[i].cnt, &ar1[i].c);
        mx = max(mx, ar1[i].x);
        mn = min(mn, ar1[i].x);
        ar1[i].id = i;
    }

    if (mx1 < mn)
    {
        kol = 0;
        res1 = 0;
        res = 0;

        for (int i = 0; i < n; i++)
            kol += ar[i].cnt;

        for (int i = 0; i < m; i++)
            ar2[i] = ar1[i];

        sort(ar1, ar1 + m, comp);
        sort(ar2, ar2 + m, comp2);

        for (int i = 0; i < m; i++)
            pos[ar1[i].id] = i;


        j = 0;
        for (int i = m - 1; i >= 0; i--)
        {
            while (j < m && kol > 0)
            {
                if (!use[ar1[j].id])
                {
                    kol1 = min(kol, ar1[j].cnt);
                    kol -= kol1;
                    ar1[j].cnt -= kol1;
                    res1 += kol1 * ar1[j].c;
                }
                if (kol > 0)
                    j++;
            }

            res = max(res, res1 - p * ar2[i].x);

            use[ar2[i].id] = 1;
            res1 -= ar2[i].c * (ar2[i].cnt - ar1[pos[ar2[i].id]].cnt);
        }

        cout << res;
        return 0;

    }


    if (n < 10000 && m < 10000)
    {
        //cout << "da" << endl;

        sort(ar, ar + n, comp1);
        sort(ar1, ar1 + m, comp2);

        kol = 0;
        res = 0;
        j = 0;
        for (int i = 0; i < m; i++)
        {
            q.insert(ar1[i]);

            while (j < n && ar[j].x <= ar1[i].x)
            {
                kol += ar[j].cnt;
                j++;
            }

            res = max(res, get(kol) - ar1[i].x * p);
        }

        q.clear();
        j = 0;
        kol = 0;
        for (int i = 0; i < n; i++)
        {
            while (j < m && ar1[j].x <= ar[i].x)
            {
                q.insert(ar1[j]);
                j++;
            }
            kol += ar[i].cnt;

            res = max(res, get(kol) - ar[i].x * p);
        }

        cout << res;
        return 0;

    }

    if (p == 0)
    {
        sort(ar1, ar1 + m, comp);
        for (int i = 0; i < m; i++)
        {
            res += min(kol, ar1[i].cnt) * ar1[i].c;
            kol -= min(kol, ar1[i].cnt);
        }

        cout << res;
        return 0;
    }

    sort(ar, ar + n, comp1);
    sort(ar1, ar1 + m, comp);

    if (mx < ar[0].x)
    {
        j = 0;
        kol = 0;
        res1 = 0;

        for (int i = 0; i < n; i++)
        {
            kol += ar[i].cnt;
            while (kol > 0 && j < m)
            {
                kol1 = min(kol, ar1[j].cnt);
                res1 += kol1 * ar1[j].c;
                kol -= kol1;
                ar1[j].cnt -= kol1;

                if (ar1[j].cnt == 0)
                    j++;
            }

            res = max(res, res1 - ar[i].x * p);
        }

        cout << res;
        return 0;
    }



    return 0;
}

/*
3 4 0
SSSS
EESW
ENWW
*/
