#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 5e5 + 10, inf = 1e9 + 1, mod = 1e9 + 993;

ll answer = 0;

int n, m;

int a[maxn], b[maxn], c[maxn];

pair<int, pair<int, int> > q[2 * maxn];

ll p;

struct treap{
    ll x, v, sum, val;
    int y;
    treap *l, *r;
};

typedef treap * ptr;

ll X = 13, Y = 17, A = 19, B = 23, C = 29;

ll myrand(){
    ll ret = (X * A + Y * B + C) % mod;
    X = Y;
    Y = ret;
    return ret;
}

ptr create(int x, int v){
    ptr t = new treap;
    t->v = v;
    t->x = x;
    t->y = myrand();
    t->l = nullptr;
    t->r = nullptr;
    t->sum = v;
    t->val = -x * v;
    return t;
}

ll val(ptr t){
    return t == nullptr ? 0 : t->val;
}

ll sum(ptr t){
    return t == nullptr ? 0 : t->sum;
}

void upd(ptr &t){
    if (t != nullptr)
        t->sum = t->v + sum(t->l) + sum(t->r), t->val = -t->x * t->v + val(t->l) + val(t->r);
}

void split(ptr t, ptr &l, ptr &r, int key){
    if (t == nullptr){
        r = nullptr;
        l = nullptr;
        return;
    }
    upd(t);
    if (t->x <= key)
        split(t->r, t->r, r, key), l = t;
    else
        split(t->l, l, t->l, key), r = t;
    upd(l);
    upd(r);
}

void merge(ptr &t, ptr l, ptr r){
    if (l == nullptr){
        t = r;
        return;
    }
    if (r == nullptr){
        t = l;
        return;
    }
    upd(l);
    upd(r);
    if (l->y <= r->y)
        merge(l->r, l->r, r), t = l;
    else
        merge(r->l, l, r->l), t = r;
    upd(t);
}

void insert(ptr &t, int x, int v){
    ptr t1, t2, it = create(x, v);
    split(t, t1, t2, x);
    merge(t, t1, it);
    merge(t, t, t2);
}

ll ans, Sum;

void find(ptr t){
    if (t == nullptr)
        return;
    if (sum(t->l) > Sum){
        find(t->l, Sum);
        return;
    }
    Sum -= sum(t->l);
    ans += val(t->l);
    if (t->v >= Sum){
        ans += -t->x * Sum;
        return;
    }
    ans += -t->x * t->v;
    find(t->r);
}

ptr root = nullptr;

int main()
{
    ifstream cin("fisher.in");
    ofstream cout("fisher.out");
    ios::sync_with_stdio(0);
    cin >> n >> m >> p;
    p *= -1;
    for (int i = 0; i < n; i++)
        cin >> q[i].first >> a[i], q[i].second = make_pair(i, 0);
    for (int i = 0; i < m; i++)
        cin >> q[i + n].first >> b[i] >> c[i], q[i + n].second = make_pair(i, 1);
    sort(q, q + n + m);
    for (int i = 0; i < n + m; i++){
        if (q[i].second.second == 0)
            Sum += a[q[i].second.first];
        else
            insert(root, -c[q[i].second.first], b[q[i].second.first]);

        ans = q[i].first * p;
        find(root);
        answer = max(answer, ans);
    }
    cout << answer;
    return 0;
}
