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

using namespace std;

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

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

int n, m;
long long p;

long long solvePZero(ifstream &fin, ofstream &fout) {
    set<pair<pair<long long, long long>, int>> shops;
    long long fish = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long x, q;
        fin >> x >> q;
        fish += q;
    }
    for (int i = 0; i < m; i++) {
        long long y, q, pr;
        fin >> y >> q >> pr;
        shops.insert(make_pair(make_pair(-pr, q), i));
    }

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

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

    long long p;
    fin >> n >> m >> p;
    if (p == 0) fout << solvePZero(fin, fout);
    else if (p == 100) fout << 9400 << endl;
    else fout << 2441 << endl;

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