#include <iostream>
#include <bits/stdc++.h>

using namespace std;

struct t
{
    long long x, a, c;
    t(){};
    t(long long y, long long z, long long r)
    {
        x = y;
        a = z;
        c = r;
    }
};

bool comp(t a, t b)
{
    return a.x < b.x;
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    long long n, m, p;
    cin >> n >> m >> p;
    vector<t> arr;
    for (long long i = 0; i < n; i++)
    {
        long long x, a;
        cin >> x >> a;
        arr.push_back(t(x, a, -1));
    }
    for (long long i = 0; i < m; i++)
    {
        long long y, b, c;
        cin >> y >> b >> c;
        arr.push_back(t(y, b, c));
    }
    sort(arr.begin(), arr.end(), comp);
    long long ans = 0;
    for (long long i = 0; i < arr.size(); i++)
    {
        long long res = 0;
        res -= p * arr[i].x;
        multiset<pair<long long, long long> > q;
        long long sum = 0;
        for (long long j = 0; j <= i; j++)
        {
            if (arr[j].c == -1)
            {
                sum += arr[j].a;
            }
            else
            {
                q.insert(make_pair(-arr[j].c, arr[j].a));
            }
        }
        multiset<pair<long long, long long> > :: iterator it = q.begin();
        while (it != q.end() && sum > 0)
        {
            if (sum >= (*it).second)
            {
                res += (*it).second * (-(*it).first);
                sum -= (*it).second;
            }
            else
            {
                res += sum * (-(*it).first);
                sum = 0;
            }
            it++;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}
