#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

const int MAX_N = 5e5;
const int MAX_M = 5e5;

pair<int, pair<int, int>> events[MAX_N + MAX_M];

int main() {
    ifstream fin("fisher.in");
    ofstream fout("fisher.out");

    int n, m, p;
    fin >> n >> m >> p;
    for (int i = 0; i < n; i++) {
        int x, a;
        fin >> x >> a;
        events[i] = make_pair(x, make_pair(a, -1));
    }
    for (int i = 0; i < m; i++) {
        int y, b, c;
        fin >> y >> b >> c;
        events[n + i] = make_pair(y, make_pair(b, c));
    }
    sort(events, events + n + m);


    int fish = 0;
    int bestAns = 0;
    set<pair<int, int>> shops; // price, quantuty;
    for (int ev = 0; ev < n + m; ev++) {
        int pos = events[ev].first, a = events[ev].second.first, b = events[ev].second.second;
        if (b == -1) {
            fish += a;
        } else {
            shops.insert(make_pair(-b, a));
        }

        int fishLeft = fish;
        int ans = 0;
        for (pair<int, int> shop: shops) {
            if (fishLeft <= 0) break;
            int price = -shop.first, q = shop.second;
            ans += min(q, fishLeft) * price;
            fishLeft -= q;
        }

        bestAns = max(bestAns, ans - p * pos);
    }

    fout << bestAns << endl;

    fin.close();
    fout.close();
    return 0;
}
