#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

void sol(int n, int m, int p)
{
    int x[n], a[n];
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &x[i], &a[i]);
    int y[m], b[m], c[m];
    for (int i = 0; i < m; ++i)
        scanf("%d%d%d", &y[i], &b[i], &c[i]);
    vector<pii> v;
    int yk1 = 0, yk2 = 0;
    for (int i = 0; i < n + m; ++i)
        if (yk1 < n && (yk2 == m || x[yk1] < y[yk2]))
            v.push_back(make_pair(yk1++, 0));
        else
            v.push_back(make_pair(yk2++, 1));
    vector<pair<pii, int> > magaz;

    for (int i = 0; i < m; ++i)
        magaz.push_back(make_pair(make_pair(c[i], b[i]), y[i]));
    sort(magaz.begin(), magaz.end());
    long long maxans = 0;
    long long sum = 0;
    int yk = 0;
    while (yk < n + m)
    {
        if (v[yk].second == 0)
            sum += a[v[yk].first];
        int coor = 0;
        if (v[yk].second == 0)
            coor = x[v[yk].first];
        else
            coor = y[v[yk].first];
        long long locans = 0;
        long long locsum = sum;
        for (int j = m - 1; j >= 0 && locsum > 0; --j)
        for (int j = m - 1; j >= 0 && locsum > 0; --j)
            if (magaz[j].second <= coor)
            {
                long long cnt = min(locsum, (long long)magaz[j].first.second);
                locsum -= cnt;
                locans += cnt * magaz[j].first.first;
            }
        locans -= (long long)p * coor;
        maxans = max(maxans, locans);
        ++yk;
    }
    cout << maxans << "\n";
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    int n, m, p;
    while (scanf("%d%d%d", &n, &m, &p) == 3)
        sol(n, m, p);
    return 0;
}
