#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()

using namespace std;
typedef long long ll;
const int MAXN = 100500;
const string NAME = "fisher"; 
ll x[MAXN];
ll y[MAXN];
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];
ll nc[MAXN];
ll arr[MAXN];
map <ll, ll> tocoord;
vector <ll> coord;
int n, m;
ll p;
ll cur;
ll ans;

struct Node
{
	int am;
	ll sum;

      	Node () {}

      	Node (int _am, ll _sum): am(_am), sum(_sum) {}
};                     

Node tree[4 * MAXN];


void upd(int v, int tl, int tr, int ind, ll val)
{
	if (tr - tl == 1)
	{
		arr[ind] += val;
		tree[v] = Node(tree[v].am + val, tree[v].sum + coord[ind] * val);    
		return;
	}

	int tm = (tl + tr) / 2;

	if (ind < tm)
		upd(2 * v, tl, tm, ind, val);
	else
		upd(2 * v + 1, tm, tr, ind, val);

	tree[v] = Node(tree[2 * v].am + tree[2 * v + 1].am, tree[2 * v].sum + tree[2 * v + 1].sum);
}

pair <Node, int> get(int v, int tl, int tr, int cnt)
{
	if (tr - tl == 1)
	{      
		if (tree[v].am <= cnt)
                	return mp(tree[v], tl);
                else
                	return mp(Node(0, 0), tr);
	}

	int tm = (tl + tr) / 2;

	if (tree[2 * v + 1].am >= cnt)
		return get(2 * v + 1, tm, tr, cnt); 
	else
	{
		pair <Node, int> c = get(2 * v, tl, tm, cnt - tree[2 * v + 1].am);
		c.first = Node(c.first.am + tree[2 * v + 1].am, c.first.sum + tree[2 * v + 1].sum);
		return c;
	}
}

void push(ll b, ll c)
{
//	cout << b << ' ' << c << ' ' << nc[c] << '\n'; 
	upd(1, 0, m, tocoord[c], b); 	
}

void recalc(ll point)
{
	pair <Node, int> kek = get(1, 0, m, cur);
	int ind = kek.second;
	ll sum = kek.first.sum;
	ll am = kek.first.am;
	            
	ll res = sum - point * p;
        
	if (ind)
	{
		ind--;
		res += (cur - am) * coord[ind];		
	}
                                                
        ans = max(ans, res);
}


int main()
{
#ifndef LOCAL                                        
	freopen((NAME + ".in").c_str(), "rt", stdin);
	freopen((NAME + ".out").c_str(), "wt", stdout);
#endif	
	ios_base::sync_with_stdio(false);

	cin >> n >> m >> p;

	forn(i, n)
		cin >> x[i] >> a[i];

	forn(i, n - 1)
		a[i + 1] += a[i];

	forn(i, m)
		cin >> y[i] >> b[i] >> c[i];

	coord.resize(m);

	forn(i, m)
	{
		coord[i] = c[i];
	}

	sort(all(coord));
	coord.resize(unique(all(coord)) - coord.begin());

	forn(i, sz(coord))
	{
		tocoord[coord[i]] = i;	
	}


	forn(i, m)
	{               
		nc[i] = tocoord[c[i]];
	}       

	int ptrx = 0;
	int ptry = 0;
                                   
        while (ptrx < n && ptry < m)
        {
        	if (x[ptrx] <= y[ptry])
        	{
			cur = a[ptrx];  
			recalc(x[ptrx]);
			ptrx++;
        	}
        	else
        	{
        		push(b[ptry], c[ptry]);
        		recalc(y[ptry]);
			ptry++;
        	}                
        }

        while (ptrx < n)
        {
		cur = a[ptrx];  
		recalc(x[ptrx]);
		ptrx++;
	}
	while (ptry < m)
	{
		push(b[ptry], c[ptry]);
       		recalc(y[ptry]);
		ptry++;
        }

        cout << ans;
        return 0;
}