#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
using namespace std;

struct event {
    int coord, idx;
    bool t;
    bool operator <(const event& other) const {
        return coord < other.coord;
    }
};

struct shop {
    int amount, price, idx;
    shop() {
        amount = price = idx = 0;
    }
    shop(int a, int b, int i) {
        amount = a;
        price = b;
        idx = i;
    }
    bool operator< (const shop& other) const {
        return price > other.price or (price == other.price and idx < other.idx);
    }
};

long long min(long long a, long long b) {
    return (a > b) ? b : a;
}
long long max(long long a, long long b) {
    return (a > b) ? a : b;
}

int main() {
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    vector<int> coords_fish(n);
    vector<int> amount_fish(n);
    vector<event> events(m + n);
    vector<int> coords_merchant(m), amount_merchant(m), price_merchant(m);
    for (int i = 0; i < n; i++) {
        cin >> coords_fish[i] >> amount_fish[i];
        events[i].coord = coords_fish[i];
        events[i].t = 0;
        events[i].idx = i;
    }
    for (int i = 0; i < m; i++) {
        cin >> coords_merchant[i] >> amount_merchant[i] >> price_merchant[i];
        events[n + i].coord = coords_merchant[i];
        events[n + i].t = 1;
        events[n + i].idx = i;
    }
    bool third_group;
    bool second_group = third_group = false;
    if (coords_merchant.back() < coords_fish[0]) {
        second_group = true;
    }
    if (coords_merchant[0] > coords_fish.back()) {
        third_group = true;
    }
    sort(events.begin(), events.end());
    set<shop> shops;
    long long avail_fish = 0;
    long long ans = 0;
    if (second_group) {
        long long curr_ans = 0;
        for (int i = 0; i < m; i++) {
            shops.insert(shop(amount_merchant[events[i].idx], price_merchant[events[i].idx], i));
        }
        for (int i = 0; i < n; i++) {
            long long curr_fish = amount_fish[events[m + i].idx];
            while (curr_fish != 0 and (!shops.empty())) {
                shop c = *shops.begin();
                long long curr_am = min(curr_fish, c.amount);
                c.amount -= curr_am;
                curr_fish -= curr_am;
                curr_ans += c.price * curr_am;
                shops.erase(shops.begin());
                if (c.amount != 0) {
                    shops.insert(c);
                }
            }
            ans = max(ans, curr_ans - (long long)events[m + i].coord * p);
        }
    } else if (third_group) {
        for (int i = 0; i < n; i++) {
            avail_fish += amount_fish[events[i].idx];
        }
        long long curr_price = 0;
        for (int i = n; i < n + m; i++) {
            shop curr_shop(amount_merchant[events[i].idx], price_merchant[events[i].idx], i);
            long long our_amount = min(curr_shop.amount, avail_fish);
            avail_fish -= our_amount;
            curr_price += our_amount * curr_shop.price;
            if (!shops.empty()) {
                auto it = shops.end();
                it--;
                shop worst_shop = *it;
                while ((!shops.empty()) and our_amount < curr_shop.amount and curr_shop.price > worst_shop.price) {
                    int curr_delta = min(curr_shop.amount - our_amount, worst_shop.amount);
                    our_amount += curr_delta;
                    curr_price += ((long long)(curr_shop.price - worst_shop.price)) * curr_delta;
                    shops.erase(worst_shop);
                    if (worst_shop.amount - curr_delta > 0) {
                        worst_shop.amount -= curr_delta;
                        shops.insert(worst_shop);
                    }
                    if (!shops.empty()) {
                        it = shops.end();
                        it--;
                        worst_shop = *it;

                    }
                }
            }
            curr_shop.amount = our_amount;
            shops.insert(curr_shop);
            ans = max(ans, curr_price - (long long)events[i].coord * p);
        }
    } else {
        vector<vector<shop> > precalc(n + m);
        if (events[0].t) {
            precalc[0] = vector<shop>{events[0].t};
        }
        for (int i = 1; i < n + m; i++) {
            if (events[i].t) {
                precalc[i].resize(precalc[i - 1].size() + 1);
                vector<shop> new_shop(1);
                new_shop[0] = shop(amount_merchant[events[i].idx], price_merchant[events[i].idx], i);
                merge(precalc[i - 1].begin(), precalc[i - 1].end(), new_shop.begin(), new_shop.end(), precalc[i].begin());
            } else {
                precalc[i] = precalc[i - 1];
            }
        }
        for (int i = 0; i < n + m; i++) {
            if (!events[i].t) {
                avail_fish += amount_fish[events[i].idx];
            } else {
                shops.insert(shop(amount_merchant[events[i].idx], price_merchant[events[i].idx], i));
            }
            if (p != 0 or i == n + m - 1) {
                long long curr_cash = 0;
                long long curr_avail_fish = avail_fish;
                for (const shop& c : shops) {
                    if (curr_avail_fish == 0) {
                        break;
                    }
                    curr_cash += (min(c.amount, curr_avail_fish) * c.price);
                    curr_avail_fish -= min(c.amount, curr_avail_fish);
                }
                ans = max(ans, curr_cash - (long long)events[i].coord * p);
            }
        }
    }
    cout << ans << endl;
}
