#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define all(v) v.begin(), v.end()
const int MAXN = 500007;

int n, m;
ll p;
int x[MAXN], y[MAXN], a[MAXN], b[MAXN], c[MAXN];

void sol1(){
    map<int, ll> t;
    ll sum = 0;
    for (int i = 0; i < n; i++){
        int tx, ta;
        cin >> tx >> ta;
        sum += ll(ta);
    }
    for (int i = 0; i < m; i++){
        int ty, tb, tc;
        cin >> ty >> tb >> tc;
        t[tc] += ll(tb);
    }
    ll ans = 0;
    while ((t.size() > 0) && (sum > 0)){
        pair<int, ll> tc = *(--t.end());
        t.erase(--t.end());
        if (tc.second <= sum){
            sum -= tc.second;
            ans += ll(tc.first) * tc.second;
        } else {
            ans += ll(tc.first) * sum;
            sum = 0;
        }
    }
    cout << ans;
}

int main(){
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    if (p == 0){
        sol1();
        return 0;
    }
    return 0;
}

