#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

struct ccc
{
    int n;
    int k;
    ccc(int n,int k):n(n),k(k){}
};

vector<ccc> bas;

bool men(ccc a,ccc b)
{
    return a.k > b.k;
}

int main()
{
    freopen("fisher.in","r",stdin);
    freopen("fisher.out","w",stdout);
    int n,m,p;
    cin >> n >> m >> p;
    bas.reserve(m);
    int64_t rub = 0;
    for(int i = 0; i < n;++i)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        rub += b;
    }
    for(int i = 0; i < m; ++i )
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        bas.push_back(ccc(b,c));
    }
    int64_t res = 0;
    sort(bas.begin(),bas.end(),men);
    for(int i = 0; i < m; ++i)
    {
        if(rub <= 0)
            break;
        int t = bas[i].n;
        int k = bas[i].k;
        if(t  <= rub)
        {
            rub -= t;
            res += t*k;
        }
        else
        {
            res += rub*k;
            rub = 0;
        }
    }
    cout << res;
}




/*
struct ver
{
    int x;
    int y;
    bool rob;
    ver(int x,int y,bool rob):x(x),y(y),rob(rob){}
    ver():x(0),y(0),rob(false){}
    ver operator =(ver a)
    {
        x = a.x;
        y = a.y;
        rob = a.rob;
        return a;
    }
};
struct ans
{
    int x;
    int y;
    int t;
    ans(int x,int y,int t):x(x),y(y),t(t){}
};
int num[1005][1005] = {0};
//int time[1005][1005] = {0};
vector<ver> par[1005][1005];
ver child[1005][1005];
ver all[1005][1005];
bool used[1005][1005] ={0};
vector<ans> res;
int ost = 0;
int time = 0;
int rasm  =0;
void dfs(int x,int y)
{
    if(used[x][y])
        return;
   if(num[x][y]>0)
   {
       used[x][y] = true;
       if(ost > 0 &&all[x][y].rob == true)
       {
            --ost;
            res.push_back(ans(x,y,time + rasm - num[x][y]%rasm));
            all[x][y].rob = false;
            ++time;
       }
       for(int i = 0;i < par[x][y].size();++i)
       {
           int nx = par[x][y][i].x;
           int ny = par[x][y][i].y;
           num[nx][ny] = num[x][y]%rasm+1;
           dfs(nx,ny);
       }
       return;
   }
   num[x][y] = 1000000;
   for(;;)
   {
       int nx,ny;
       nx = child[x][y].x;
       ny = child[x][y].y;
       if(num[nx][ny] > 0)
       {
           ost = num[nx][ny]-num[x][y]+1;
           rasm = ost;
           break;
       }
       num[nx][ny] = num[x][y]-1;
       x = nx;
       y = ny;
   }
    dfs(x,y);
    return;
}
int main()
{
    freopen("robots.in","r",stdin);
    freopen("robots.out","w",stdout);
    res.reserve(1000000);
    int n,m,g;
    cin >> n >> m >> g;
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            all[i1][i].x = i1;
            all[i1][i].y = i;
        }
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            char c;
            scanf(" %c",&c);
            if(c - 'A' >= 0 && c - 'A' <= 30)
                all[i1][i].rob = true;
            if(c == 'N' || c == 'n')
            {
                child[i1][i] = all[i1][i-1];
                par[i1][i-1].push_back(all[i1][i]);
            }
            if(c == 'S' || c == 's')
            {
                child[i1][i] = all[i1][i+1];
                par[i1][i+1].push_back(all[i1][i]);
            }
            if(c == 'W' || c == 'w')
            {
                child[i1][i] = all[i1-1][i];
                par[i1-1][i].push_back(all[i1][i]);
            }
            if(c == 'E' || c == 'e')
            {
                child[i1][i] = all[i1+1][i];
                par[i1+1][i].push_back(all[i1][i]);
            }
        }
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            if(num[i1][i] <= 0)
            {
                time = 0;
                rasm = 0;
                ost = 0;
                dfs(i1,i);
            }
        }
    cout << res.size()<<'\n';
    if(g == 1)
    {
        for(int i = 0; i < res.size();++i)
            cout << res[i].y << ' ' << res[i].x << ' ' << res[i].t << '\n';
    }
    cout << endl;
     for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
            cout << i1 << ' ' << i << ' ' <<num[i1][i] <<endl;
    return 0;
}
*/
/*
3 4 1
SSSS
EESW
ENWW

4 4 1
essS
Eess
Snww
EeWN
*/
