#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

struct pa
{
    int x,a,k;
};

pa a[200030];
pa b[200030];

bool comp1 (pa x, pa y)
{
    return (x.k > y.k);
}

int main()
{
    freopen("fisher.in","r",stdin);
    freopen("fisher.out","w",stdout);
    int i,j,n,m,p;
    long long r = 0;
    long long ot;
    ot = 0;
    cin >> n >> m >> p;
    for (i = 0; i<n; i++)
    {
        cin >> a[i].x >> a[i].a;
        r += a[i].a;
        b[i].k = 0;
    }
    for (i = 0; i < m; i++)
    {
        cin >> b[i].x >> b[i].a >> b[i].k;
    }
    sort(b,b+m, comp1);
    for (i = 0; i<m; i++)
    {
        if (r >= b[i].a)
        {
            ot += b[i].a * b[i].k;
            r -= b[i].a;
        }
        else
        if (r > 0)
        {
            ot += r * b[i].k;
            r = 0;
        }
        else
            break;
    }
    cout << ot << endl;






}
/*

3 2 0
1 5
2 3
4 5
2 2 10
3 6 5

*/
