#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;


struct base{
    long long x, b, c;
};



bool ls1(pair <int, int> p1, pair <int, int> p2) {
    if (p1.second < p2.second) return true;
    else if (p1.second > p2.second) return false;
    else if (p1.first < p2.first) return true;
    else return false;
}


bool ls(base b1, base b2) {
    if (b1.c < b2.c) return true;
    else return false;
}


int main() {
    ifstream fin;
    fin.open("fisher.in");
    ofstream fout;
    fout.open("fisher.out");
    int n, m, p;
    long long summa, tmp;
    pair <int, int> event;
    base tmp_base;
    fin >> n >> m >> p;
    vector <pair <int, int> > places(n);
    vector <base> bases(m);
    //vector <pair <int, int> > events(n + m);
    summa = 0;
    for (int i = 0 ; i < n; i ++) {
        fin >> event.first >> event.second;
        places[i] = event;
        //events[i] = event;
        summa += event.second;
    }
    for (int i = 0; i < m; i ++) {
        fin >> tmp_base.x >> tmp_base.b >> tmp_base.c;
        bases[i] = tmp_base;
        //events[i + n] = event;
    }
    if (p == 0) {
        sort(bases.begin(), bases.end(), ls);
        long long counter = 0;
        for (int i = m - 1; i >= 0; i--) {
            tmp = min(summa, bases[i].b);
            counter += tmp * bases[i].c;
            summa -= tmp;
        }
        fout << counter;
    } else {
        long long now, maximum, fish;
        fish = 0;
        now = 0;
        maximum = 0;
        sort(bases.begin(), bases.end(), ls);
        reverse(bases.begin(), bases.end());
        int j = 0;
        for (int i = 0; i < n; i ++) {
            if (i == 0) {
                now -= p * places[0].first;
            } else {
                now -= p * (places[i].first - places[i - 1].first);
            }
            //cout << now << ' ';
            fish += places[i].second;
            while (fish > 0 && j < m) {
                if (fish < bases[j].b) {
                    tmp = fish;
                    now += tmp * bases[j].c;
                    bases[j].b -= tmp;
                    fish -= tmp;
                } else {
                    tmp = bases[j].b;
                    now += tmp * bases[j].c;
                    bases[j].b -= tmp;
                    fish -= tmp;
                }
                if (bases[j].b == 0) {
                    j ++;
                }
            }
            maximum = max(maximum, now);
            //cout << now << ' ' << fish << '\n';
        }
        fout << maximum;
    }
    fin.close();
    fout.close();
    return 0;
}
