#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<long long> 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;
    }
    if (lst[m - 1][1] < s[0].first){
        vector<vector<long long> > dp(n);
        for (int i = 0; i < n; i++)
            dp[i].resize(2);
        dp[0][0] = s[0].first;
        dp[0][1] = s[0].second;
        for (int i = 1; i < n; i++){
            dp[i] = dp[i - 1];
            dp[i][0] = s[i].first;
            dp[i][1] += s[i].second;
        }
        vector<long long> answer(n);
        for (int i = 0; i < n; i++)
            answer[i] = 0;
        int cur = 0;
        int now = 0;
        sort(lst.begin(), lst.end());
        reverse(lst.begin(), lst.end());
        long long pr = 0;
        while (cur < m && now < n){
            if (now > 0){
                answer[now] = answer[now - 1];
                dp[now][1] -= pr;
            }
            pr = dp[now][1];
            while (cur < m){
                answer[now] += lst[cur][0] * min(lst[cur][2], dp[now][1]);
                long long k = lst[cur][2];
                lst[cur][2] -= min(lst[cur][2], dp[now][1]);
                dp[now][1] -= min(k, dp[now][1]);
                if (dp[now][1] != 0)
                    cur += 1;
                else
                    break;
            }
            now += 1;
        }
        int x = 0;
        for (int i = 0; i < n; i++)
            if (answer[i] - p * dp[i][0] > answer[x] - p * dp[x][0])
                x = i;
        if (answer[x] - p * dp[x][0] > 0)
            cout << answer[x] - p * dp[x][0] << endl;
        else
            cout << 0;
    }
    return 0;
}

