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

bool comp(const tuple<int, int, int> &a, const tuple<int, int, int> &b)
{
    return get<2>(a) > get<2>(b);
}
pair<int, int> fish[50000];
tuple <int, int, int> money[50000];
int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m;
    long long p;
    cin >> n >> m >> p;
    for (int i = 0; i < n; i++)
        cin >> fish[i].first >> fish[i].second;
    for (int i = 0; i < m; i++)
    {
        int x, b, c;
        cin >> x >> b >> c;
        money[i] = make_tuple(x, b, c);
    }
    if (p == 0)
    {
        long long f = 0;
        for (int i = 0; i < n; i++)
            f += fish[i].second;
        sort(money, money + m, comp);
        long long ans = 0;
        for (int i = 0; i < m && f > 0; i++)
        {
            ans += min((long long)get<1>(money[i]), f) * get<2>(money[i]);
            f -= get<1>(money[i]);
        }
        cout << ans << endl;
    }
}
