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

using namespace std;


int main(){
    ifstream in("fisher.in");
    ofstream out("fisher.out");
    long long n, m, p;
    in >> n >> m >> p;
    if(p == 0){
        long long res = 0, a, b, c;
        for(long long i = 0; i < n; i++){
            in >> a >> b;
            res += b;
        }
        long long money = 0;
        vector<vector<long long> > v(m, vector<long long> (2));
        for(long long i = 0; i < m; i++){
            in >> a >> v[i][1] >> v[i][0];
        }
        sort(v.rbegin(), v.rend());
        for(long long i = 0; i < m; i++){
            long long j = min(res, v[i][1]);
            res -= j;
            money += j * v[i][0];
        }
        out << money;
    }
    else{
        vector<long long> x(n);
        vector<long long> a(n);
        vector<long long> y(m);
        vector<vector<long long> > coins(m, vector<long long> (2));
        for(long long i = 0; i < n; i++){
            in >> x[i] >> a[i];
        }
        for(long long j = 0; j < m; j++){
            in >> y[j] >> coins[j][1] >> coins[j][0];
        }
        sort(coins.rbegin(), coins.rend());
        if(y[m - 1] < x[0]){
            long long res = 0;
            long long l = 0;
            for(long long i = 0; i < n; i++){
                res += a[i];
                long long e = 0;
                long long h = 0;

                while(res > 0  and h < coins.size()){
                    long long u = min(res, coins[h][1]);
                    e += u * coins[h][0];
                    res -= u;
                    h += 1;
                    coins[h][1] -= u;
                }
                cout << "iuhiuh";
                l = max(l, e - x[i] * p);
            }
            out << l;
        }
    }
    return 0;
}
