#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;
        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;
    return 0;
}
