#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long n, m, p;
vector <long long> a, b, c, x, y;
int main()
{
	freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	a.resize(n);
	b.resize(m);
	c.resize(m);
	x.resize(n);
	y.resize(m);
	long long can;
	pair <long long, long long> e;
    for (long long i = 0; i < n; ++i)
        cin >> x[i] >> a[i];
    set <pair<long long, long long> > s;
    for (long long i = 0; i < m; ++i)
    {
        cin >> y[i] >> b[i] >> c[i];
        s.insert(make_pair(c[i], b[i]));

    }
    long long sum = 0, ans = 0, tek = 0;
    if (x[0] > y[m - 1])
    {
        for (long long i = 0; i < n; ++i)
        {
            sum += a[i];
            if (i == 0)
                tek -= x[0] * p;
            else
                tek -= (x[i] - x[i - 1]) * p;
            while(s.size() != 0 && sum > 0)
            {
                e.first = s.begin()->first;
                e.second = s.begin()->second;
                can = min(sum, e.second);
                sum -= can;
                tek += e.first * can;
                s.erase(s.begin());
                if (can < e.second)
                    s.insert(make_pair(e.first, e.second - can));
            }
            if (tek > ans)
                ans = tek;
        }
    }
    else
    if (y[0] > x[n - 1])
    {

    }
    else
    if (p == 0)
    {
        sum = 0;
        tek = 0;
        ans = 0;
        for (int i = 0; i < m; ++i)
        {
            sum += a[i];
        }
        while (sum > 0 && s.size() != 0)
        {
            e.first = s.begin()->first;
            e.second = s.begin()->second;
            can = min(sum, e.second);
            sum -= can;
            tek += e.first * can;
            s.erase(s.begin());
            if (can < e.second)
                s.insert(make_pair(e.first, e.second - can));
        }
        ans = tek;
    }
    else
    {

    }
    cout << ans;
}
