#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int n, m, p;
class temp
{
public:
    long long c, x, b;
    temp(long long _x, long long _b, long long _c)
    {
        x = _x;
        b = _b;
        c = _c;
    }
};

bool comp(temp a, temp b)
{
    if (a.c > b.c)
        return 1;
    else
        return 0;
}
vector <pair <long long, long long> > gg;
vector <temp> ss;

int main()
{
    //freopen("castle.in", "r", stdin);
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin >> n >> m >> p;
    if (p == 0)
    {
        long long ans = 0;
        long long pp = 0;
        long long x, a, c;
        for (int i = 0; i < n; i++)
        {
            cin >> x >> a;
            pp += a;
        }

        for (int i = 0; i < m; i++)
        {
            cin >> x >> a >> c;
            gg.push_back(make_pair(c, a));
        }
        sort(gg.begin(), gg.end());
        for (int i = m - 1; i >= 0 && pp > 0; i--)
        {
            ans += (min(pp, gg[i].second) * gg[i].first);
            pp -= min(pp, gg[i].second);
        }
        cout << ans;
    }
    else
    {
        long long ans = 0;
        long long mini = 0;
        long long pp = 0, p0 = 0;
        long long x, a, c, maxx = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> x >> a;
            gg.push_back(make_pair(x, a));
        }
        int j = 0;
        for (int i = 0; i < m; i++)
        {
            cin >> x >> a >> c;
            mini = 0;
            //cout << j << " " << gg[j].first << endl;
            for (; j < n && gg[j].first < x; j++)
            {
                pp += gg[j].second;
                mini = 0;
                mini -= p * max(maxx, gg[j].first);
                p0 = pp;
                for (int k = 0; k < ss.size() && p0 > 0; k++)
                {
                    mini += (min(p0, ss[k].b) * ss[k].c);
                    p0 -= min(p0, ss[k].b);
                }
                ans = max(ans, mini);
                //cout << ans << " " << i << " " << j << endl;
            }
            maxx = x;
            ss.push_back(temp(x, a, c));
            sort(ss.begin(), ss.end(), comp);
            mini = 0;
            mini -= p * maxx;
            p0 = pp;
            for (int k = 0; k < ss.size() && p0 > 0; k++)
            {
                //cout << mini << endl;
                mini += (min(p0, ss[k].b) * ss[k].c);
                p0 -= min(p0, ss[k].b);
            }
            ans = max(ans, mini);
        }
        mini = 0;
        for (; j < n; j++)
        {
            pp += gg[j].second;
            mini = 0;
            mini -= p * max(maxx, gg[j].first);
            p0 = pp;
            for (int k = 0; k < ss.size() && p0 > 0; k++)
            {
                //cout << mini << endl;
                mini += (min(p0, ss[k].b) * ss[k].c);
                p0 -= min(p0, ss[k].b);
            }
            ans = max(ans, mini);
        }
        cout << ans;
    }

}
