#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, long long> fish[50000];
tuple <int, long long, long long> money[50000];
long long dp[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;
        return 0;
    }
    if (fish[0].first > get<0>(money[m - 1]))
    {
        sort(money, money + m, comp);
        int ind = 0;
        long long pref = 0;
        long long ans = 0;
        for (int i = 0; i < n; i++)
        {
            long long cnt = -(fish[i].first - pref) * p;
            while (fish[i].second > 0 || ind == m)
            {
                cnt += min((long long)get<1>(money[ind]), fish[i].second) * get<2>(money[ind]);
                if (fish[i].second < get<1>(money[ind]))
                {
                    get<1>(money[ind]) -= fish[i].second;
                    fish[i].second = 0;
                }
                else
                {
                    fish[i].second -= get<1>(money[ind++]);
                }
            }
            pref = fish[i].first;
            ans += cnt;
            dp[i] = ans;
        }
        ans = 0;
        for (int i = 0; i < n; i++)
            ans = max(ans, dp[i]);
        cout << ans << endl;
        return 0;
    }
}
