#include <bits/stdc++.h>

using namespace std;

struct node
{
    int prior;
    node* l;
    node* r;
    int64_t price, b;
    int64_t sum_price, sum_b;
    node(int64_t _p, int64_t _b) : prior(rand()), l(NULL), r(NULL), price(_p), b(_b), sum_price(_p*_b), sum_b(_b){};

};
typedef node* trep;

inline int64_t get_sum_price(trep p)
{
    return p ? p->sum_price : 0;
}

inline int64_t get_sum_b(trep p)
{
    return p ? p->sum_b : 0;
}

void recalc(trep p)
{
    if (!p) return;
    p->sum_price = p->price*p->b + get_sum_price(p->l) + get_sum_price(p->r);
    p->sum_b = p->b + get_sum_b(p->l) + get_sum_b(p->r);
}

void split(int val, trep p, trep& l, trep& r)
{
    if (!p)
        l = r = NULL;
    else if (p->price >= val)
        split(val, p->r, p->r, r),
        l = p;
    else
        split(val, p->l, l, p->l),
        r = p;
    recalc(l);
    recalc(r);
}

void merge(trep& p, trep l, trep r)
{
    if (!(l && r))
        p = l ? l : r;
    else if (l->prior > r->prior)
        merge(l->r, l->r, r),
        p = l;
    else
        merge(r->l, l, r->l),
        p = r;
    recalc(p);
}

int64_t get(trep p, int64_t have)
{
    if (!p)
        return 0;
    if (have < get_sum_b(p->l))
        return get(p->l, have);
    int64_t ans = get_sum_price(p->l);
    have -= get_sum_b(p->l);

    if (have < p->b)
        return ans + have * p->price;

    ans += p->b * p->price;
    have -= p->b;

    if (have)
        ans += get(p->r, have);

    return ans;

}

class Shop
{

    trep body;

public:

    Shop(): body(NULL){};

    void add(int b, int c)
    {
        trep l(NULL), r(NULL);
        split(c, body, l, r);
        body = new node(c, b);
        merge(l, l, body);
        merge(body, l, r);
    }

    inline int64_t sold(int64_t a)
    {
        return get(body, a);
    }

    void _cerr()
    {
        cerr << get_sum_b(body) << ' ' << get_sum_price(body) << endl;
    }

};

struct act
{
    int type;
    int x, a, c;
    act(int t, int _x, int _a, int _c=0): type(t), x(_x), a(_a), c(_c) {};

    bool operator<(const act& other) const
    {
        if (x == other.x)
            return type < other.type;
        return x < other.x;
    }

    void pr()
    {
        cout << type << ' ' << x << ' ' << a << ' ' << c << endl;
    }
};

void main_solve(int n, int m, int p)
{

    vector<act> acts;
    acts.reserve(n+m);

    for (int i = 0; i < n; ++i)
    {
        int x, a;
        cin >> x >> a;
        acts.emplace_back(0, x, a);
    }

    for (int i = 0; i < m; ++i)
    {
        int y, b, c;
        cin >> y >> b >> c;
        acts.emplace_back(1, y, b, c);
    }

    sort(acts.begin(), acts.end());

    Shop shop;
    int64_t have(0);
    int64_t ans(0);
    for (act& it : acts)
    {
        if (it.type)
            shop.add(it.a, it.c);
        else
            have += it.a;
        ans = max(ans, shop.sold(have) - (int64_t)p*it.x);
    }

    cout << ans << endl;

    return;

}

void solve_p0(int n, int m)
{
    int64_t sum(0);

    int c;
    for (int i = 0; i < n; ++i)
    {
        int c, a;
        cin >> c >> a;
        sum += a;
    }

    vector<pair<int, int> > can(m);
    for (auto& it : can)
        cin >> c >> it.second >> it.first;

    sort(can.rbegin(), can.rend());

    int64_t ans(0);
    for (auto it : can)
    {
        if (sum < it.second)
        {
            ans += sum*it.first;
            break;
        }
        ans += (int64_t)it.first*it.second;
        sum -= it.second;
    }

    cout << ans << endl;
    return;
}

void solve()
{
    int n, m, p;
    cin >> n >> m >> p;

    if (!p)
        solve_p0(n, m);
    else
        main_solve(n, m, p);
}

#define FILE_NAME "fisher"

int main()
{
#ifndef __DEBUG
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif // __DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie();
    srand(time(NULL));

    solve();

    return 0;
}
