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

int main() {
    ifstream cin("fisher.in");
    ofstream cout("fisher.out");
    long long n, m, p, x;
    long long sum = 0;
    cin >> n >> m >> p;
    for (int i = 0; i < n; i++) {
        cin >> x >> p;
        sum += p;
    }
    pair <long long, long long> markets[m];
    for (int i = 0; i < m; i++) {
        cin >> x >> markets[i].second >> markets[i].first;
    }
    sort(markets, markets + m, greater<pair<long long, long long> >());
    long long res = 0, tosell;
    for (int i = 0; i < m; i++) {
        tosell = min(sum, (long long)markets[i].second);
        sum -= tosell;
        //cout <<  tosell << ' ' << markets[i].first << endl;
        res += tosell * markets[i].first;
    }
    cout << res;
    return 0;
}
