#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ciso646>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <initializer_list>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

time_t _timer;
void _pre()
{
	_timer = clock();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef ANDREIKKAA
	assert(freopen("input.txt", "r", stdin) != nullptr);
#else
	assert(freopen("fisher.in", "r", stdin) != nullptr);
	assert(freopen("fisher.out", "w", stdout) != nullptr);
#endif
}

void _post()
{
#ifdef ANDREIKKAA
	cout << "\n\n\nTime: " << (clock() - _timer) / (ld)CLOCKS_PER_SEC << endl;
	while (228);
#endif
}

struct event
{
	bool type;
	int x;
	int count, cost;
};

bool cmp(const event* a, const event *b)
{
	if (a->x != b->x)
		return a->x < b->x;
	return a->type < b->type;
}

struct Node
{
	ll cost;
	ll count;
	ll dp_cost;
	ll dp_count;
	int l, r;
	int pri;
} t[500228];
int mem = 1;

inline ll get_count(int v)
{
	if (v == 0)
		return 0;
	return t[v].dp_count;
}

inline ll get_cost(int v)
{
	if (v == 0)
		return 0;
	return t[v].dp_cost;
}
inline void recalc(int v)
{
	t[v].dp_cost = get_cost(t[v].l) + t[v].cost * t[v].count + get_cost(t[v].r);
	t[v].dp_count = get_count(t[v].l) + t[v].count + get_count(t[v].r);
}

int merge_t(int a, int b)
{
	if (a == 0)
		return b;
	if (b == 0)
		return a;
	if (t[a].pri > t[b].pri)
	{
		t[a].r = merge_t(t[a].r, b);
		recalc(a);
		return a;
	}
	else
	{
		t[b].l = merge_t(a, t[b].l);
		recalc(b);
		return b;
	}
}

pair<int, int> split_t(int v, ll x)
{
	if (v == 0)
		return{ 0, 0 };

	if (x > t[v].cost)
	{
		auto res = split_t(t[v].l, x);
		t[v].l = res.second;
		recalc(v);
		return{ res.first, v };
	}
	else
	{
		auto res = split_t(t[v].r, x);
		t[v].r = res.first;
		recalc(v);
		return{ v, res.second };
	} 
}

ll splay_t(int v, ll x)
{
	if (v == 0)
		return 0;

	auto lft = get_count(t[v].l);
	if (lft >= x)
	{
		return splay_t(t[v].l, x);
	}
	
	x -= lft;
	ll ans = get_cost(t[v].l);
	
	if (t[v].count >= x)
	{
		ans += x * t[v].cost;
		return ans;
	}

	return ans + splay_t(t[v].r, x - t[v].count) + t[v].count * t[v].cost;
}

int root = 0;
inline void add_t(ll cnt, ll cst)
{
	auto p1 = split_t(root, cst);
	auto p2 = split_t(p1.first, cst + 1);
	if (p2.second != 0)
	{
		assert(t[p2.second].count == t[p2.second].dp_count);
		assert(t[p2.second].cost == cst);
		t[p2.second].count += cnt;
		t[p2.second].dp_count += cnt;
		t[p2.second].dp_cost += cnt * cst;
	}
	else
	{
		t[mem].cost = cst;
		t[mem].count = cnt;
		t[mem].dp_cost = cst * cnt;
		t[mem].dp_count = cnt;
		t[mem].pri = rand();
		p2.second = mem;
		++mem;
	}
	root = merge_t(merge_t(p2.first, p2.second), p1.second);
}

inline ll get_t(ll x)
{
	return splay_t(root, x);
}

void _solve()
{
	static event* e[1000228], *f[500228], *g[500228];

	int n, m;
	ll p;
	cin >> n >> m >> p;

	for (int i = 0; i < n; ++i)
	{
		int x, a;
		cin >> x >> a;
		f[i] = new event{0, x, a, 0};
	}

	for (int i = 0; i < m; ++i)
	{
		int y, b, c;
		cin >> y >> b >> c;
		g[i] = new event{1, y, b, c};
	}
	e[0] = new event{0, 0, 0, 0};
	merge(f, f + n, g, g + m, e + 1, cmp);

	ll ans = 0;
	ll cur = 0;
	ll fish = 0;

	for (int i = 1; i <= n + m; ++i)
	{
		cur += p * (e[i]->x - e[i - 1]->x);
		if (e[i]->type == 0)
		{
			fish += e[i]->count;
		}
		else
		{
			add_t(e[i]->count, e[i]->cost);
		}
		ans = max(ans, get_t(fish) - cur);
	}

	cout << ans << endl;
}

int main()
{
	_pre();
	_solve();
	_post();
}