#include <bits/stdc++.h>

using namespace std;

pair<long long, long long> mas[(int)5e5 + 10];
pair<long long, long long> a[(int)5e5 + 10];

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    long long p;
    cin >> n >> m >> p;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < m; i++)
    {
        long long x;
        cin >> x >> mas[i].second >> mas[i].first;
        mas[i].first *= -1;
    }
    sort(mas, mas + m);
    sort(a, a + n);
    long long ans = 0;
    long long sum = 0;
    int j = 0;
    for (int i = 0; i < n; i++)
    {
        while (j < m && a[i].second > 0)
        {
            long long t = min(mas[j].second, a[i].second);
            a[i].second -= t;
            mas[j].second -= t;
            sum -= mas[j].first * t;
            if (mas[j].second == 0)
                j++;
        }
        ans = max(ans, sum - p * a[i].first);
    }
    cout << ans << endl;
    return 0;
}
