#pragma comment(linker,"/stack:256000000")

#include <fstream>
//#include <iostream>
#include <algorithm>

#define lll long long
using namespace std;


struct smth
{
	bool base;
	lll x, tns, prc, key;
	bool operator<(const smth& y)
	{
		return x < y.x;
	}
};

struct nd;

struct tree
{
	nd* rt;
	lll sum_tns, sum_mon;
	lll func(const lll& tns);
	void add(const smth& smt);
	void merge(const tree& t1, const tree& t2);
	void split(tree& t1, tree& t2, const lll& value);
};

struct nd
{
	tree lef, rig;
	lll key, prc, tns;
};

void tree::add(const smth& smt)
{
	tree t1, t2, t;
	split(t1, t2, smt.prc);
	t.rt = new nd[1];
	t.rt->key = smt.key;
	t.rt->prc = smt.prc;
	t.rt->tns = smt.tns;
	t.rt->lef.rt = NULL;
	t.rt->rig.rt = NULL;
	t.sum_mon = smt.prc * smt.tns;
	t.sum_tns = smt.tns;
	t.rt->lef.sum_mon = 0;
	t.rt->lef.sum_mon = 0;
	t.rt->rig.sum_tns = 0;
	t.rt->rig.sum_tns = 0;
	merge(t1, t);
	t1.rt = rt;
	merge(t1, t2);
}

void tree::split(tree& t1, tree& t2, const lll& value)
{
	if (rt == NULL)
	{
		t1.rt = NULL;
		t1.sum_tns = 0;
		t1.sum_mon = 0;
		t2.rt = NULL;
		t2.sum_tns = 0;
		t2.sum_mon = 0;
	}
	else
	{
		tree t;
		if (value < rt->prc)
		{
			rt->rig.split(t1, t2, value);
			rt->rig = t1;
			t1.rt = rt;
			if (t1.rt != NULL)
			{
				t1.sum_tns = t1.rt->tns + t1.rt->lef.sum_tns + t1.rt->rig.sum_tns;
				t1.sum_mon = t1.rt->prc * t1.rt->tns + t1.rt->lef.sum_mon + t1.rt->rig.sum_mon;
			}
			else
			{
				t1.sum_tns = 0;
				t1.sum_mon = 0;
			}
		}
		else
		{
			rt->lef.split(t1, t2, value);
			rt->lef = t2;
			t2.rt = rt;
			if (t2.rt != NULL)
			{
				t2.sum_tns = t2.rt->tns + t2.rt->lef.sum_tns + t2.rt->rig.sum_tns;
				t2.sum_mon = t2.rt->prc * t2.rt->tns + t2.rt->lef.sum_mon + t2.rt->rig.sum_mon;
			}
			else
			{
				t2.sum_tns = 0;
				t2.sum_mon = 0;
			}
		}
	}
}

void tree::merge(const tree& t1, const tree& t2)
{
	if (t1.rt == NULL)
		rt = t2.rt;
	else if (t2.rt == NULL)
		rt = t1.rt;
	else if (t1.rt->key < t2.rt->key)
	{
		merge(t1.rt->rig, t2);
		t1.rt->rig.rt = rt;
		rt = t1.rt;
	}
	else
	{
		merge(t1, t2.rt->lef);
		t2.rt->lef.rt = rt;
		rt = t2.rt;
	}
	if (rt != NULL)
	{
		sum_tns = rt->lef.sum_tns + rt->rig.sum_tns + rt->tns;
		sum_mon = rt->lef.sum_mon + rt->rig.sum_mon + rt->tns * rt->prc;
	}
	else
	{
		sum_tns = 0;
		sum_mon = 0;
	}
}

lll tree::func(const lll& tns)
{
	if (tns >= sum_tns)
		return sum_mon;
	if (tns <= 0)
		return 0;
	if (tns <= rt->lef.sum_tns)
		return rt->lef.func(tns);
	if (tns >= rt->lef.sum_tns + rt->tns)
		return rt->lef.sum_mon + rt->tns + rt->rig.func(tns - rt->lef.sum_tns - rt->tns);
	return rt->lef.sum_mon + (tns - rt->lef.sum_tns) * rt->prc;
}

int main()
{
	ifstream cin("fisher.in");
	ofstream cout("fisher.out");
	srand(42);
	tree dek;
	dek.rt = NULL;
	dek.sum_mon = 0;
	dek.sum_tns = 0;
	lll n, m, p;
	cin >> n >> m >> p;
	smth* smt;
	smt = new smth[n + m];
	lll i;
	for (i = 0; i < n; ++i)
	{
		(smt + i)->base = false;
		cin >> (smt + i)->x >> (smt + i)->tns;
	}
	for (i = 0; i < m; ++i)
		(smt + i + n)->key = i;
	lll t, j;
	for (i = 0; i < m; ++i)
	{
		j = (rand() * 32000 + rand()) % m;
		if (j < 0)
			j = -j;
		if (i != j)
		{
			t = (smt + i)->key;
			(smt + i + n)->key = (smt + j)->key;
			(smt + j + n)->key = t;
		}
	}
	for (i = 0; i < m; ++i)
	{
		(smt + i + n)->base = true;
		cin >> (smt + i + n)->x >> (smt + i + n)->tns >> (smt + i + n)->prc;
	}
	sort(smt, smt + m + n);
	lll fish = 0, ans = 0;
	m += n;
	for (i = 0; i < m; ++i)
	{
		if ((smt + i)->base)
			dek.add(smt[i]);
		else
			fish += (smt + i)->tns;
		t = -p * (smt + i)->x + dek.func(fish);
		if (ans < t)
			ans = t;
	}
	cout << ans;
	return 0;
}