#include <bits/stdc++.h>

using namespace std;

pair<long long, int> mas[(int)5e5 + 10];
long long a[(int)5e5 + 10];
long long b[(int)5e5 + 10];
long long c[(int)5e5 + 10];
const int debug = 0;

long long my_rand()
{
    return ((rand() << 16ll + rand()) << 16ll + rand()) << 16ll + rand();
}

struct tree
{
    long long a, b, y, col1, col2, sum1, sum2;
    tree *l, *r;
    tree(): a(0), b(0), y(0), col1(0), col2(0), sum1(0), sum2(0), l(NULL), r(NULL) {}
    tree(long long _a, long long _b)
    {
        a = _a;
        b = _b;
        y = my_rand();
        col1 = 0;
        col2 = 0;
        sum1 = 0;
        sum2 = 0;
        l = NULL;
        r = NULL;
    }
};

long long col(tree* v)
{
    if (v == NULL)
        return 0;
    return (v->col1) + (v->col2) + (v->b);
}

long long sum(tree* v)
{
    if (v == NULL)
        return 0;
    else
        return (v->sum1) + (v->sum2) + ((v->a) * (v->b));
}

pair<tree*, tree*> split(tree* v, long long a)
{
    if (v == NULL)
    {
        return {NULL, NULL};
    }
    if ((v->a) > a)
    {
        pair<tree*, tree*> p = split(v->l, a);
        v->l = p.second;
        p.second = v;
        v->sum1 = sum(v->l);
        v->col1 = col(v->l);
        return p;
    }
    else
    {
        pair<tree*, tree*> p = split(v->r, a);
        v->r = p.first;
        p.first = v;
        v->sum2 = sum(v->r);
        v->col2 = col(v->r);
        return p;
    }
}

tree* merge(tree* v1, tree* v2)
{
    if (v1 == NULL)
        return v2;
    if (v2 == NULL)
        return v1;
    if ((v1->y) < (v2->y))
    {
        v1->r = merge(v1->r, v2);
        v1->col2 = col(v1->r);
        v1->sum2 = sum(v1->r);
        return v1;
    }
    else
    {
        v2->l = merge(v1, v2->l);
        v2->col1 = col(v2->l);
        v2->sum1 = sum(v2->l);
        return v2;
    }
}

tree* ins(tree* v, long long a, long long b)
{
    pair<tree*, tree*> p = split(v, a);
    pair<tree*, tree*> q = split(p.first, a - 1);
    if (q.second == NULL)
        q.second = new tree(a, b);
    else
        q.second->b += b;
    p.first = merge(q.first, q.second);
    v = merge(p.first, p.second);
    return v;
}

long long summ(tree* v, long long a)
{
    if (v == NULL || a == 0)
        return 0;
    if (debug) cout << v->a << " " << v->b << " " << v->col1 << " " << v->sum1 << " " << v->col2 << " " << v->sum2 << " " << a << endl;
    if ((v->col2) >= a)
        return summ(v->r, a);
    long long ans = v->sum2;
    a -= v->col2;
    long long t = min(a, v->b);
    if (debug) cout << "!" << t << endl;
    a -= t;
    ans += t * (v->a);
    return ans + summ(v->l, a);
}

int main()
{
    freopen("fisher.in", "r", stdin);
    freopen("fisher.out", "w", stdout);
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    long long p;
    cin >> n >> m >> p;
    tree* v = NULL;
    for (int i = 0; i < n; i++)
    {
        long long x;
        cin >> x >> a[i];
        mas[i] = {x, i + 1};
    }
    for (int i = 0; i < m; i++)
    {
        long long x;
        cin >> x >> b[i] >> c[i];
        mas[i + n] = {x, -i - 1};
    }
    sort(mas, mas + n + m);
    long long ans = 0;
    long long sum = 0;
    for (int i = 0; i < n + m; i++)
    {
        if (mas[i].second > 0)
        {
            sum += a[mas[i].second - 1];
        }
        else
        {
            v = ins(v, c[-mas[i].second - 1], b[-mas[i].second - 1]);
        }
        long long qwe = summ(v, sum);
        if (debug) cout << "                            " << mas[i].first << " " << mas[i].second << " " << qwe << " " << qwe - p * mas[i].first << endl;
        ans = max(ans, qwe - p * mas[i].first);
    }
    cout << ans << endl;
    return 0;
}
