#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);
    long long num = 1;
    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 < pair <long long, long long>, long long> > s, s2;
    for (long long i = 0; i < m; ++i)
    {
        cin >> y[i] >> b[i] >> c[i];
        ++num;
        s.insert(make_pair(make_pair(-c[i], -b[i]), num));

    }

    long long sum = 0, ans = 0, tek = 0;
    if (x[0] > y[m - 1] || p == 0)
    {
        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.first;
                e.second = -s.begin()->first.second;
                can = min(sum, e.second);
                sum -= can;
                tek += e.first * can;
                s.erase(s.begin());
                //cout << e.first << ' ' << e.second << ' ' << sum << ' ' <<tek << endl;
                ++num;
                if (can < e.second)
                    s.insert(make_pair(make_pair(-e.first, -(e.second - can)), num));
            }
            if (tek > ans)
                ans = tek;
        }
    }
    else
    {
        int r = 0;
        long long sum2 = 0;
        s.clear();
        x.push_back(1e+9 + 4);
        a.push_back(0);
        int old = -1;
        y.push_back(1e+9+15);
        for (int i = 0; i < n; ++i)
        {
            sum += a[i];
            sum2 = sum;

            while(y[r] <= x[i + 1])
                ++r;
            --r;
            for (int qi = old + 1; qi <= r; ++qi)
            {
                ++num, s.insert(make_pair(make_pair(-c[qi], -b[qi]), num));
                s2 = s;
                tek = -max(y[qi], x[i]) * p;

                while (s.size() != 0 && sum > 0)
                {
                    e.first = -s.begin()->first.first;
                    e.second = -s.begin()->first.second;
                    can = min(sum, e.second);
                    sum -= can;
                    tek += e.first * can;
                    s.erase(s.begin());
                    ++num;
                    if (can < e.second)
                        s.insert(make_pair(make_pair(-e.first, -(e.second - can)), num));
                }
                if (tek > ans)
                    ans = tek;
                s = s2;
                sum = sum2;
            }
            old = r;
        }

    }

    cout << ans;
}
