#include <stdio.h>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
 
pair <long long, int> aa[100005];
long long b[100005];
long long a[100005];
long long x[100005];
long long y[100005];
 
int main()
{
    ios::sync_with_stdio(false);
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    long long n, m, p;
    cin >> n >> m >> p;
 
    if (p == 0)
    {
    long long maxc = 0;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        long long x, y;
        cin >> x >> y;
        sum += y;
        maxc = max(maxc, x);
    }
 
    for (int i = 0; i < m; i++)
    {
        long long x, y, z;
        cin >> x >> b[i] >> aa[i].first;
        aa[i].second = i;
        maxc = max(maxc, x);
    }
    sort(aa, aa + m);
    reverse(aa, aa + m);
 
    long long ans = 0;
    for (int i = 0; i < m; i++)
    {
        int v = aa[i].second;
        ans += min(sum, b[v]) * aa[i].first;
        sum -= min(sum, b[v]);
    }
    //if (p == 0)
        //cout << ans << endl;
    //else
        cout << ans << endl;
    }
    else
    {
        long long ans = 0;
        long long sum = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> x[i] >> a[i];                            
        }
 
        for (int i = 0; i < m; i++)
        {
            cin >> y[i] >> b[i] >> aa[i].first;
            aa[i].second = i;
            sum += b[i];
        }
 
        int i;
        long long cntsum = 0;
        for (i = 0; i < n; i++)
        {
            cntsum += a[i]; 
            if (cntsum >= sum)
                break;
        }
        if (i == n)
            i--;
        ans -= p * x[i];
        sort(aa, aa + m);
        reverse(aa, aa + m);
        sum = cntsum;
 
        for (int i = 0; i < m; i++)
        {
            int v = aa[i].second;
            ans += min(sum, b[v]) * aa[i].first;
            sum -= min(sum, b[v]);
        } 
        cout << ans << endl;
    }
    return 0;
}