#include <iostream>
#include <fstream>
#include <random>
#include <ctime>

using namespace std;

struct random{
    const static int64_t a = 1e9 + 7, b = 1e9 + 9, c = 1e12 + 39, d = 1e9 + 3337;
    int64_t pr = 0, ppr = 0;
    int64_t gen()
    {
        int64_t t = (a * pr + b * ppr + c) % d;
        ppr = pr, pr = t;
        return t;
    }
    int64_t operator()()
    {
        return (gen() << 17) ^ (gen() << 34) ^ gen();
    }
} myrand;

//int myrand()
//{
//    return rand();
//}

struct vertex{
    int64_t y;
    int64_t w, tw, c, tc, rc;
    vertex *l, *r;
} dump[500001], *root, *ne = dump;

typedef vertex* ptr;

const int N = 500001;
int64_t ans, p, a[N];
int n, m, x[N], y[N], w[N], c[N];

int64_t stw(ptr r)
{
    return r? r->tw: 0;
}

int64_t stc(ptr r)
{
    return r? r->tc: 0;
}

int64_t src(ptr r)
{
    return r? r->rc: 0;
}

void refresh(ptr r)
{
    if (r)
        r->tw = stw(r->l) + stw(r->r) + r->w,
        r->tc = stc(r->l) + stc(r->r) + r->c;
}

ptr merge(ptr l, ptr r)
{
    if (!l || !r)
        return ptr(uint64_t(l) + uint64_t(r));
    if (l->y < r->y)
        return l->r = merge(l->r, r), refresh(l), l;
    else
        return r->l = merge(l, r->l), refresh(r), r;
}

void splitw(ptr root, ptr& l, ptr& r, int64_t w)
{
    if (!root)
        return void(l = r = 0);
    if (stw(root->l) >= w)
        r = root, splitw(r->l, l, r->l, w), refresh(r);
    else
        l = root, splitw(l->r, l->r, r, w - stw(l->l) - l->w), refresh(l);
}

void splitrc(ptr root, ptr& l, ptr& r, int64_t rc)
{
    if (!root)
        return void(l = r = 0);
    if (src(root) > rc)
        l = root, splitrc(l->r, l->r, r, rc), refresh(l);
    else
        r = root, splitrc(r->l, l, r->l, rc), refresh(r);
}

void add(int i)
{
    ptr a = ne++;
    a->y = myrand();
    a->w = w[i];
    a->rc = c[i];
    a->c = a->rc * w[i];
    refresh(a);
    ptr l, r;
    splitrc(root, l, r, a->rc);
    root = merge(merge(l, a), r);
}

int64_t getc(int64_t w)
{
    if (w == 0)
        return 0;
    ptr l, r, t;
    if (stw(root) > w)
    {
        splitw(root, l, r, w);
        t = l;
        while (t->r)
            t = t->r;
        int64_t ans = stc(l) - t->c + (w - stw(l) + t->w) * t->rc;
        root = merge(l, r);
        return ans;
    }
    else
        return stc(root);
}

int main()
{
    ifstream cin("fisher.in");
    ofstream cout("fisher.out");
    srand(time(0));
    cin >> n >> m >> p;
    for (int i = 0; i < n; ++i)
        cin >> x[i] >> a[i];
    for (int i = 0; i < m; ++i)
        cin >> y[i] >> w[i] >> c[i];
    x[n] = y[m] = 1e9 + 5;
    int l = 0, r = 0;
    int64_t cw = 0, cc = 0;
    while (l < n || r < m)
    {
        if (x[l] < y[r])
            cw += a[l], cc = x[l++] * p;
        else
            add(r), cc = y[r++] * p;
        ans = max(ans, getc(cw) - cc);
    }
    cout << ans;
    return 0;
}
