#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <numeric>
#include <ctime>
#include <cassert>
#include <set>

using namespace std;

typedef long long nagai;

char ch[400000000];
int ptr = 0;
void* operator new(size_t n)
{
	ptr += n;
	return ch + ptr - n;
}
void operator delete(void* v)
{

}

struct nd
{
	nd* le;
	nd* ri;
	int l, r;
	nagai bsum, bcsum, mx;
	nd(int l, int r)
		: bsum(0), bcsum(0), mx(-1), l(l), r(r), le(nullptr), ri(nullptr)
	{}
	int m()
	{
		return (l + r) / 2;
	}
	int len()
	{
		return r - l;
	}

	void children()
	{
		if (!le)
			le = new nd(l, m());
		if (!ri)
			ri = new nd(m(), r);
	}
	void add(int c, int b)
	{
		if (c < l || c >= r)
			return;
		if (r - l == 1)
		{
			bsum += b;
			bcsum += 1LL * b * c;
			if (bsum != 0)
				mx = c;
			return;
		}
		children();
		le->add(c, b);
		ri->add(c, b);
		bsum = le->bsum + ri->bsum;
		bcsum = le->bcsum + ri->bcsum;
		mx = max(le->mx, ri->mx);
	}

	nagai getb(int l1, int r1)
	{
		if (l1 <= l && r <= r1)
			return bsum;
		if (l1 >= r || l >= r1)
			return 0;
		children();
		return le->getb(l1, r1) + ri->getb(l1, r1);
	}
	nagai getbc(int l1, int r1)
	{
		if (l1 <= l && r <= r1)
			return bcsum;
		if (l1 >= r || l >= r1)
			return 0;
		children();
		return le->getbc(l1, r1) + ri->getbc(l1, r1);
	}

	nagai getmx(int l1, int r1)
	{
		if (l1 <= l && r <= r1)
			return mx;
		if (l1 >= r || l >= r1)
			return -1;
		children();
		return max(le->getmx(l1, r1), ri->getmx(l1, r1));
	}
};

vector<int> b, c;

int lessb(nd* n, nagai b)
{
	if (n->r - n->l == 1)
		return n->r;
	nagai curs = 0;
	n->children();
	while (n->ri->bsum > b)
		n = n->ri, n->children();
	if (n->r - n->l == 1)
		return n->r;
	return lessb(n->le, b - n->ri->bsum);
}

struct ev
{
	int x, id;
	bool shop;
	ev(int x, int id, bool shop)
		: x(x), id(id), shop(shop)
	{}
	bool operator <(const ev& b) const
	{
		if (x != b.x)
			return x < b.x;
		if (shop != b.shop)
			return shop < b.shop;
		return id < b.id;
	}

	bool operator !=(const ev& b) const
	{
		return x != b.x || id != b.id || shop != b.shop;
	}
};


int main()
{
	freopen("fisher.in", "r", stdin);
	ofstream cout("fisher.out");
	auto tstart = clock();
	int n, m, p;
	scanf("%d %d %d", &n, &m, &p);
	vector<nagai> x(n), a(n);
	for (int i = 0; i < n; ++i)
	{
		int x1, a1;
		scanf("%d %d", &x1, &a1);
		x[i] = x1;
		a[i] = a1;
	}
	vector<nagai> y(m);
	b.resize(m);
	c.resize(m);
	for (int i = 0; i < m; ++i)
	{
		int y1;
		scanf("%d %d %d", &y1, &b[i], &c[i]);
		y[i] = y1;
	}
	int sm = 0;
	vector<ev> evs;
	for (int i = 0; i < n; ++i)
		evs.push_back({ (int)x[i], i, false });
	for (int i = 0; i < m; ++i)
		evs.push_back({ (int)y[i], i, true });

	sort(evs.begin(), evs.end());
	nagai curfish = 0;
	nagai mx = 0;
	b.push_back(0);
	c.push_back(0);
	int cnt1 = 0;
	int SZ = 1000001;
	nd* rt = new nd(0, SZ);
	for (auto& e : evs)
	{
		nagai ans = e.shop ? -y[e.id] * p : -x[e.id] * p;
		if (!e.shop)
			curfish += a[e.id];
		else
			rt->add(c[e.id], b[e.id]);
		if (rt->getb(0, SZ) <= curfish)
		{
			ans += rt->getbc(0, SZ);
			mx = max(mx, ans);
			continue;
		}
		int ind = lessb(rt, curfish);
		ans += rt->getbc(ind, SZ);
		auto c1 = rt->getmx(0, ind);
		ans += 1LL * c1 * (curfish - rt->getb(ind, SZ));
		mx = max(mx, ans);
	}
	cout << mx << endl;
}