#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

struct tp1
{
    int x, a;
};

struct tp2
{
    int y, b, c;
};

int n, m, p;
tp1 a[1000000];
tp2 b[1000000];

bool comp1(tp2 a, tp2 b)
{
    return a.c > b.c;
}


int main()
{
    ios_base::sync_with_stdio(false);
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> p;

    long long sum1 = 0;
    long long sum2 = 0;

    for (int i = 1; i <= n; i++)
    {
        int x1, a1;
        cin >> x1 >> a1;
        a[i] = {x1, a1};

        sum1 += a1;
    }

    for (int i = 1; i <= m; i++)
    {
        int y1, b1, c1;
        cin >> y1 >> b1 >> c1;
        b[i] = {y1, b1, c1};
    }

    sort(b + 1, b + m + 1, comp1);

    long long ans = 0;
    for (int i = 1; i <= m; i++)
    {
        if (sum1 >= b[i].b)
        {
            sum1 -= b[i].b;
            ans += b[i].b * b[i].c;
        } else
        {
            ans += sum1 * b[i].c;
            sum1 = 0;
        }
    }

    cout << ans << endl;
    return 0;
}
