#include <bits/stdc++.h>

#define size(cont) int(cont.size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define llong long long

#ifdef HOME
    #define filename "file"
#else
    #define filename "fisher"
#endif // HOME

constexpr llong inf = (llong) 1e9 + 7ll;
char buff[(int) 1e6 + 17];

inline void config_io(bool __fastio)
{
    if (__fastio)
    {
        std::ios_base::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }

    freopen(filename".in", "r", stdin);

#ifndef HOME
    freopen(filename".out", "w", stdout);
#endif
}

using namespace std;

const int maxn = (int) 1e6 + 17;

int n, m, p;
llong a[maxn], x[maxn], y[maxn];
pair<llong, llong> b[maxn];
pair< pair<llong, llong>, llong> c[maxn];

int main()
{
    config_io(false);

    scanf("%d %d %d", &n, &m, &p);

    for (int i = 0; i < n; ++i)
        scanf("%lld %lld", &x[i], &a[i]);

    for (int j = 0; j < m; ++j)
        scanf("%lld %lld %lld", &y[j], &b[j].second, &b[j].first);

    if (p == 0)
    {
        sort(b, b + m);

        llong sum = 0, ans = 0;

        for (int i = 0; i < n; ++i)
            sum += a[i];

        for (int j = m - 1; j >= 0; --j)
        {
            if (b[j].second >= sum)
                ans += sum * b[j].first;
            else
                ans += b[j].second * b[j].first;

            sum -= b[j].second;
            sum = max(0ll, sum);

            if (sum == 0)
                break;
        }

        return printf("%lld", ans), 0;
    }

    if (n <= 10000)
    {
        for (int i = 0; i < m; ++i)
            c[i] = {b[i], y[i]};

        sort(c, c + m);
        llong ans = 0, sum = 0;

        for (int i = 0; i < n; ++i)
        {
            sum += a[i];
            llong cursum = sum;
            llong cans = 0ll;

            for (int j = m - 1; j >= 0; --j)
                if (c[j].second <= x[i])
                {
                    if (c[j].first.second >= sum)
                        cans += sum * c[j].first.first;
                    else
                        cans += c[j].first.second * c[j].first.first;

                    sum -= c[j].first.second;
                    sum = max(0ll, sum);

                    if (sum == 0)
                        break;
                }

            ans = max(ans, cans - x[i] * p);

            sum = cursum;
        }

        return printf("%lld", ans), 0;
    }

    return 0;
}
