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

#define xx first
#define yy second
typedef pair<long long, long long> pii;
typedef long long ll;

int n, m, p;
pii xa[50002];
pair <ll, pii> ybc[50002];

bool cmp(pair<ll, pii> x, pair<ll, pii> y)
{
    if(y.yy.yy == x.yy.yy)
    {
        if(y.yy.xx == x.yy.xx)
            return y.xx > x.xx;
        return y.yy.xx > x.yy.xx;
    }
    return y.yy.yy > x.yy.yy;
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> xa[i].xx >> xa[i].yy;
        sum += xa[i].yy;
    }
    for(int i = 0; i < m; i++)
        cin >> ybc[i].xx >> ybc[i].yy.xx >> ybc[i].yy.yy;
    sort(ybc, ybc + m, cmp);
    ll ans = 0;
    for(int i = 0; i < m; i++)
    {
        ans += (ll)min(sum, ybc[i].yy.xx) * (ll)ybc[i].yy.yy;
        sum -= min(sum, ybc[i].yy.xx);
    }
    cout << ans;
    return 0;
}
