#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 5e5 + 10, inf = 1e9 + 1, mod = 1e9 + 993;

ll answer = 0;

int n, m;

ll a[maxn], b[maxn], c[maxn];

pair<ll, pair<int, int> > q[2 * maxn];

ll p;

multiset<pair<ll, ll> > s;

int main()
{
    ifstream cin("fisher.in");
    ofstream cout("fisher.out");
    ios::sync_with_stdio(0);
    cin >> n >> m >> p;
    p *= -1;
    for (int i = 0; i < n; i++)
        cin >> q[i].first >> a[i], q[i].second = make_pair(i, 0);
    for (int i = 0; i < m; i++)
        cin >> q[i + n].first >> b[i] >> c[i], q[i + n].second = make_pair(i, 1);
    sort(q, q + n + m);
    ll sum = 0;
    for (int i = 0; i < n + m; i++){
        if (q[i].second.second == 0)
            sum += a[q[i].second.first];
        else
            s.insert(make_pair(-c[q[i].second.first], b[q[i].second.first]));
        ll now = sum;
        ll ans = p * q[i].first;
        for (auto it : s)
            if (it.second <= now)
                now -= it.second, ans -= it.second * it.first;
            else{
                ans -= now * it.first;
                break;
            }
        answer = max(answer, ans);
    }
    cout << answer;
}
