#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <vector>


using namespace std;


vector<int> make_vector(int a, int b){
    vector<int> s(2);
    s[0] = a;
    s[1] = b;
    return s;
}


void print(vector<char> s){
    for (int i = 0; i < s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}


char trans(char x){
    if (x == 'S')
        return 'D';
    if (x == 'N')
        return 'U';
    if (x == 'E')
        return 'R';
    if (x == 'W')
        return 'L';
    if (x == 's')
        return 'd';
    if (x == 'n')
        return 'u';
    if (x == 'e')
        return 'r';
    if (x == 'w')
        return 'r';
}


int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    cin >> n >> m >> p;
    vector<pair<int, int> > s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i].first >> s[i].second;
    vector<vector<long long> > lst(m);
    for (int i = 0; i < m; i++){
        lst[i].resize(3);
        cin >> lst[i][1] >> lst[i][2] >> lst[i][0];
    }
    if (p == 0){
        long long summa = 0;
        for (int i = 0; i < n; i++)
            summa += s[i].second;
        long long answer = 0;
        sort(lst.begin(), lst.end());
        reverse(lst.begin(), lst.end());
        for (int i = 0; i < m; i++){
            answer += lst[i][0] * min(lst[i][2], summa);
            summa -= min(lst[i][2], summa);
        }
        cout << answer;
        return 0;
    }
    return 0;
}

