#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, cnt1;
};

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];


vector <mag> q;

void change(ll &kol, mag m)
{
    ll kol1;

    q.pb(m);
    int j = q.size() - 2;
    while (j >= 0 && q[j].c < q[j + 1].c)
    {
        swap(q[j], q[j + 1]);
        j--;
    }

    j = 0;
    while (j < q.size() && kol > 0)
    {
        kol1 = min(kol, q[j].cnt);
        res1 += kol1 * q[j].c;
        q[j].cnt -= kol1;
        kol -= kol1;
        j++;
    }

    for (int i = q.size() - 1; i > 0; i--)
    {
        kol1 = min(q[i].cnt, q[i - 1].cnt1 - q[i - 1].cnt);
        res1 -= kol1 * q[i].c;
        res1 += kol1 * q[i - 1].c;
        q[i].cnt += kol1;
        q[i - 1].cnt -= kol1;
    }

}

void change1(ll &kol)
{
    ll kol1;

    j = 0;
    while (j < q.size() && kol > 0)
    {
        kol1 = min(kol, q[j].cnt);
        res1 += kol1 * q[j].c;
        q[j].cnt -= kol1;
        kol -= kol1;
        j++;
    }
}

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);
    }

    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);
        ar1[i].id = i;
        ar1[i].cnt1 = ar1[i].cnt;
    }

        //cout << "da" << endl;

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

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

        change(kol, ar1[i]);

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

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

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

    cout << res;
    return 0;

    return 0;
}

/*
3 4 0
SSSS
EESW
ENWW
*/
