#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;
    vector<pair<int, int> > arr_y;
    vector<pair<int, int> > arr_x;
    int min_x = 1e9;
    int max_y = 0;
    for (long long i = 0; i < n; i++)
    {
        long long x, a;
        cin >> x >> a;
        arr.push_back(t(x, a, -1));
        arr_x.push_back(make_pair(x, a));
        if (x < min_x)
            min_x = x;
    }
    for (long long i = 0; i < m; i++)
    {
        long long y, b, c;
        cin >> y >> b >> c;
        arr.push_back(t(y, b, c));
        arr_y.push_back(make_pair(-c, b));
        if (y > max_y)
            max_y = y;
    }
    sort(arr_y.begin(), arr_y.end());
    sort(arr.begin(), arr.end(), comp);
    long long ans = 0;
    //cout << max_y << " " << min_x << endl;
    if (max_y < min_x)
    {
        int ans = 0;
        vector<int> sum;
        vector<int> d;
        int l1 = 0;
        int cost = 0;
        for (int i = 0; i < arr_y.size(); i++)
        {
            l1 += arr_y[i].second;
            sum.push_back(l1);
            cost += (-arr_y[i].first) * arr_y[i].second;
            d.push_back(cost);
        }
        /*cout << sum.size() << endl;
        for (int i = 0; i < sum.size(); i++)
        {
            cout << sum[i] << " ";
        }
        cout << endl;
        for (int i = 0; i < d.size(); i++)
            cout << d[i] << " ";
        cout << endl;*/
        int e = 0;
        for (int i = 0; i < arr_x.size(); i++)
        {
            int res = 0;
            e += arr_x[i].second;
            res -= p * arr_x[i].first;
            //cout << arr_x[i].first << endl;
            int l = -1;
            int r = arr_y.size();
            while(r - l > 1)
            {
                int m = (r + l) / 2;
                if (sum[i] > e)
                    r = m;
                else
                    l = m;
            }
            if (l != -1)
                res += d[l];
            if (l != -1)
                e -= sum[l];
            //cout << l << endl;
            //cout << e << endl;
            //cout << res << endl;
            //cout << l << " " << arr_y.size() - 1 <<"::::" <<  endl;
            if (l  != arr_y.size() - 1)
            {
                res += e * (-arr_y[l + 1].first);
                //cout << " !!!!" << endl;
            }
            //cout << res << endl;
            ans = max(res, ans);
        }
        cout << ans << endl;
        return 0;
    }

    if (p == 0)
    {
        int i = arr.size() - 1;
        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++;
        }
        cout << res << endl;
        return 0;
    }


    long long sum1 = 0;
    multiset<pair<long long, long long> > q;
    for (long long i = 0; i < arr.size(); i++)
    {
        long long res = 0;
        res -= p * arr[i].x;
        if (arr[i].c == -1)
            sum1 += arr[i].a;
        long long sum = sum1;
        if (arr[i].c != -1)
        {
            q.insert(make_pair(-arr[i].c, arr[i].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;
}
