#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 1e5;

const int MAXX = 1e6 + 10;

struct Event
{
	ll x, cnt, type, mul;

	Event () {}
	Event (int xx, int cc, int mm, int tt) : x(xx), cnt(cc), mul(mm), type(tt) {}
};

struct Node
{
	ll key, sum;
};

bool cmp(Event a, Event b)
{
	if (a.x != b.x)
		return a.x < b.x;
	return a.type < b.type;
}

Node tree[MAXX * 4];

void upd(int v, int l, int r, int i, ll c)
{
		// printf("%d %d %d\n", l, r, i);
	if (i < l || r <= i)
		return;
	if (r - l == 1)
	{
		// printf("%lld\n", l);
		tree[v].sum += c;
		tree[v].key = (ll)l * tree[v].sum;
		return;
	}
	ll m = (l + r) / 2;
	if (l <= i && i < m)
		upd(2 * v, l, m, i, c);
	else
		upd(2 * v + 1, m, r, i, c);
	tree[v].sum = tree[2 * v].sum + tree[2 * v + 1].sum;
	tree[v].key = tree[2 * v].key + tree[2 * v + 1].key;
}

ll search(int v, int l, int r, ll c)
{
	if (r - l == 1)
		return l;
	int m = (l + r) / 2;
	ll x = tree[2 * v + 1].sum;
	if (x <= c)
		return search(2 * v, l, m, c - x);
	return search(2 * v + 1, m, r, c);
}

ll get_ans(int v, int l, int r, int L, int R)
{
	if (r <= L || R <= l)
		return 0;
	// printf("%d %d %d %d\n", l, r, L, R);
	if (L <= l && r <= R)
		return tree[v].key;

	int m = (l + r) / 2;

	ll x = 0;

	if (!(m <= L || R <= l))
		x = get_ans(2 * v, l, m, L, R);
	if (!(r <= L || R <= m))
		x += get_ans(2 * v + 1, m, r, L, R);

	return x;
}

ll get_sum(int v, int l, int r, int L, int R)
{
	if (r <= L || R <= l)
		return 0;
	if (L <= l && r <= R)
		return tree[v].sum;

	int m = (l + r) / 2;

	ll x = 0;

	if (!(m <= L || R <= l))
		x = get_sum(2 * v, l, m, L, R);
	if (!(r <= L || R <= m))
		x += get_sum(2 * v + 1, m, r, L, R);

	return x;
}

Event v[MAXX];
int ptr;

int get_int()
{
	int c = getchar_unlocked();

	while (c < '0' || '9' < c)
		c = getchar_unlocked();

	int ret = 0;

	while ('0' <= c && c <= '9')
	{
		ret = (ret * 10 + c - '0');
		c = getchar_unlocked();
	}


	return ret;
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);


	int n, m;
	ll p;
	n = get_int();
	m = get_int();
	p = get_int();

	// vector <Event> v;

	for (int i = 0; i < n; ++i)
	{
		int x, a;
		x = get_int();
		a = get_int();
		v[ptr++] = (Event(x, a, 0, 0));
	}

	for (int i = 0; i < m; ++i)
	{
		int x, a, mul;
		// scanf("%d%d%d", &x, &a, &mul);
		x = get_int();
		a = get_int();
		mul = get_int();
		v[ptr++] = (Event(x, a, mul, 1));
	}

	v[ptr++] = (Event(0, 0, 0, 0));

	sort(v, v + ptr, cmp);

	ll cnt = 0;
	ll ans = 0;

	for (int i = 1; i < ptr; ++i)
	{
		if (v[i].type == 0)
		{
			cnt += v[i].cnt;
		}
		else if (v[i].type == 1)
		{
			upd(1, 0, MAXX, v[i].mul, v[i].cnt);
		}
		// printf("%lld\n", cnt);

		// printf("%lld %lld\n", tree[2].sum, tree[2].key);

		ll l = search(1, 0, MAXX, cnt);

		ll cur = get_ans(1, 0, MAXX, l + 1, MAXX) + (cnt - get_sum(1, 0, MAXX, l + 1, MAXX)) * l;
		// printf("%lld\n", l);
		ans = max(ans, cur - p * v[i].x);
	}

	printf("%lld\n", ans);








	return 0;
}