#include <bits/stdc++.h>0

using namespace std;

#define forn(i, n) for (int i = 0; i < n; i++)
#define sqr(a) ((a) * (a))
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define sz(a) (a.size())
#define all(a) a.begin(), a.end()
#define NAME "fisher"
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);

typedef long long ll;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int INF = 2e9;
const ll INF64 = 9e18;
const int N = 500100;
const int M = 1010;

int n, m;
ll ans, pp, a[N], x[N], y[N], b[N], c[N];
ll t[N * 4], tt[N * 4];
vector < int > xx, cc;
unordered_set < int > ss;
ll sum1, sum2;

void update(int v, int tl, int tr, int ind, int val)
{
    if (tl == tr)
    {
        t[v] += val;
        tt[v] = t[v] * cc[tl - 1];
        return;
    }
    int tm = (tl + tr) / 2;
    if (ind <= cc[tm - 1])
        update(v * 2, tl, tm, ind, val);
    else
        update(v * 2 + 1, tm + 1, tr, ind, val);
    t[v] = t[v * 2] + t[v * 2 + 1];
    tt[v] = tt[v * 2] + tt[v * 2 + 1];
}

void get(int v, int tl, int tr)
{
    if (tl == tr)
    {
        if (t[v] <= sum2)
        {
            sum1 += tt[v];
            sum2 -= t[v];
        }
        else
        {
            sum1 += cc[tl - 1] * (ll)sum2;
            sum2 = 0;
        }
        return;
    }
    int tm = (tl + tr) / 2;
    if (t[v * 2 + 1] <= sum2)
    {
        sum1 += tt[v * 2 + 1];
        sum2 -= t[v * 2 + 1];
        get(v * 2, tl, tm);
    }
    else
        get(v * 2 + 1, tm + 1, tr);
}


int main()
{
    FREOPEN;
    cin >> n >> m >> pp;
    forn(i, n)
    {
        scanf("%I64d %I64d", &x[i], &a[i]);
        xx.pb(x[i]);
    }
    forn(i, m)
    {
        scanf("%I64d %I64d %I64d", &y[i], &b[i], &c[i]);
        xx.pb(y[i]);
        if (!ss.count(c[i]))
        {
            ss.insert(c[i]);
            cc.pb(c[i]);
        }
    }
    sort(all(xx));
    sort(all(cc));
    int ncc = sz(cc);
    int sxx = sz(xx);
    int i = 0, j = 0;
    ll sum = 0, mm = 0;
    forn(u, sxx)
        if (u == 0 || xx[u - 1] != xx[u])
        {
            int q = xx[u];
            while (3 == 3)
            {
                if ((i == n || x[i] > q) && (j == m || y[j] > q))
                    break;
                if (j == m)
                {
                    sum += a[i];
                    i++;
                }
                else
                {
                    if (i == n || y[j] < x[i])
                    {
                        update(1, 1, ncc, c[j], b[j]);
                        j++;
                    }
                    else
                    {
                        sum += a[i];
                        i++;
                    }
                }
                sum1 = 0;
                sum2 = sum;
                get(1, 1, ncc);
                ans = max(ans, sum1 - q * pp);
            }

        }

    cout << ans;
    return 0;
}


/*

3 2 0
1 5
2 3
4 5
2 2 10
3 6 5


2 1 100
6 5
100 4
5 100 2000


3 3 10
1 1
10 100
20 10
2 1000 1
11 50 50
17 50 2




*/




