#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e6+5;
const int MAXC = 1e6;

struct P
{
    ll cnt, cst;
    P *l, *r;

    P(){l=r=NULL;}
    P(P* p)
    {
        cnt = p->cnt;
        cst = p->cst;
        l = p->l;
        r = p->r;
    }
};

int n, m;
ll p;
int x[MAXN];
int y[MAXN];
int a[MAXN];
int b[MAXN];
int c[MAXN];
vector <int> arr;
P *t[MAXN];
ll ans = 0;

P* build(P* t, int tl, int tr)
{
    t = new P;

    if (tl == tr)
    {
        t->cnt = 0;
        t->cst = 0;
        return t;
    }

    int tm = (tl+tr)/2;
    t->l = build(t->l, tl, tm);
    t->r = build(t->r, tm+1, tr);
    t->cnt = 0;
    t->cst = 0;

    return t;
}

P* update(P* t, int tl, int tr, int pos, int x)
{
    P *nt = new P(t);

    if (tl == tr)
    {
        nt->cnt = t->cnt+x;
        nt->cst = nt->cnt*pos;
        return nt;
    }

    int tm = (tl+tr)/2;
    if (pos <= tm) nt->l = update(nt->l, tl, tm, pos, x);
    else           nt->r = update(nt->r, tm+1, tr, pos, x);

    nt->cnt = nt->l->cnt + nt->r->cnt;
    nt->cst = nt->l->cst + nt->r->cst;

    return nt;
}

ll get(P* t, int tl, int tr, ll cnt)
{
    if (t->cnt < cnt) return t->cst;
    if (tl == tr) return cnt*tl;

    int tm = (tl+tr)/2;
    if (t->r->cnt >= cnt) return get(t->r, tm+1, tr, cnt);
    else return t->r->cst + get(t->l, tl, tm, cnt-t->r->cnt);
}

int main()
{
    //freopen("in.txt", "r", stdin);
    freopen("fisher.in", "r", stdin), freopen("fisher.out", "w", stdout), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    cin >> n >> m >> p;
    for (int i = 0; i < n; i++) cin >> x[i] >> a[i], arr.push_back(x[i]);
    for (int i = 0; i < m; i++) cin >> y[i] >> b[i] >> c[i], arr.push_back(y[i]);
    sort(arr.begin(), arr.end());
    arr.resize(unique(arr.begin(), arr.end()) - arr.begin());

    t[0] = NULL;
    t[0] = build(t[0], 0, MAXC);
    for (int i = 0; i < m; i++) t[i+1] = update(t[i], 0, MAXC, c[i], b[i]);

    for (int w = 0; w < arr.size(); w++)
    {
        static int i=0, j=0;
        static ll cnt=0, oil;

        while (i < n && x[i] <= arr[w]) cnt += a[i++];
        while (j < m && y[j] <= arr[w]) j++;

        oil = p*max((i > 0 ? x[i-1] : 0), (j > 0 ? y[j-1] : 0));

        ans = max(ans, get(t[j], 0, MAXC, cnt)-oil);
    }

    cout << ans;

    return 0;
}
