#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int N = 500050;

ll x[N], y[N], a[N];
pair < ll, ll > b[N];

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    ios::sync_with_stdio(0);
    int n, m;
    ll p;
    cin >> n >> m >> p;
    for (int i = 0; i < n; i++)
        cin >> x[i] >> a[i];
    for (int i = 0; i < m; i++)
        cin >> y[i] >> b[i].second >> b[i].first;
    if (p == 0) {
        ll cnt = 0, sum = 0;
        for (int i = 0; i < n; i++)
            cnt += a[i];
        sort(b, b + m);
        reverse(b, b + m);
        for (int i = 0; i < m; i++)
            if (cnt < b[i].second) {
                sum += cnt * b[i].first;
                break;
            }
            else {
                sum += b[i].first * b[i].second;
                cnt -= b[i].second;
            }
        cout << sum;
    }

    return 0;
}
