#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <cmath>

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

using namespace std;

typedef long long int ll;
typedef long double ld;

const int MAX_N = 1000 * 1000 + 5;

struct point
{
	ll at;
	ll cost;
	ll can;
	int type;
};

bool cmp(const point &a, const point &b)
{
	return a.at < b.at || (a.at == b.at && a.type < b.type);
}

int n, m;
ll p;
point arr[MAX_N];
ll tree_cnt[4 * MAX_N];
ll tree_cost[4 * MAX_N];
ll have[MAX_N];
map<int, ll> costs;
ll now = 0;


int x, y;
ll add;
ll get(ll tree[], int v, int l, int r)
{
	if (r <= x || y <= l)
	{
		return 0;
	}
	else if (x <= l && r <= y)
	{
		return tree[v];
	}
	else
	{
		int m = (l + r) >> 1;
		return get(tree, 2 * v + 1, l, m) + get(tree, 2 * v + 2, m, r);
	}
}

void upd(ll tree[], int v, int l, int r)
{
	if (r <= x || x < l)
	{
		return;
	}
	else if (r - l == 1)
	{
		tree[v] += add;
	}
	else
	{
		int m = (l + r) >> 1;
		upd(tree, 2 * v + 1, l, m);
		upd(tree, 2 * v + 2, m, r);
		tree[v] = tree[2 * v + 1] + tree[2 * v + 2];
	}
}

ll need = 0;
ll answer_now = 0;
int get_at(int v, int l, int r)
{
	if (r - l == 1)
	{
		return l;
	}
	else
	{
		int m = (l + r) >> 1;
		if (tree_cnt[2 * v + 2] >= need)
		{
			return get_at(2 * v + 2, m, r);
		}
		else
		{
			need -= tree_cnt[2 * v + 2];
			answer_now += tree_cost[2 * v + 2];
			return get_at(2 * v + 1, l, m);
		}
	}
}

ll calc()
{
	ll answer = 0;
	ll at = now;

	for (auto it = costs.rbegin(); it != costs.rend(); ++it)
	{
		if (it->second <= at)
		{
			answer += it->second*it->first;
			at -= it->second;
		}
		else
		{
			answer += at*it->first;
			break;
		}
	}

	return answer;
}

ll calc2()
{
	need = now;
	answer_now = 0;
	int pos = get_at(0, 0, MAX_N);

	return answer_now + pos*need;
}

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

	scanf("%d %d %lld", &n, &m, &p);

	for (int i = 0; i < n; ++i)
	{
		scanf("%lld %lld", &arr[i].at, &arr[i].can);
		arr[i].type = -1;
	}
	for (int i = 0; i < m; ++i)
	{
		scanf("%lld %lld %lld", &arr[i + n].at, &arr[i + n].can, &arr[i + n].cost);
		arr[i + n].type = 1;
	}

	n += m;
	sort(arr, arr + n, cmp);

	ll answer = 0;

	memset(tree_cnt, 0, sizeof(tree_cnt));
	memset(tree_cost, 0, sizeof(tree_cost));
	memset(have, 0, sizeof(have));
	for (int i = 0; i < n; ++i)
	{
		if (arr[i].type == -1)
		{
			now += arr[i].can;
			answer = max(answer, calc2() - arr[i].at*p);
		}
		else
		{
			x = arr[i].cost;
			add = arr[i].can;
			upd(tree_cnt, 0, 0, MAX_N);
			x = arr[i].cost;
			add = arr[i].can*arr[i].cost;
			upd(tree_cost, 0, 0, MAX_N);
			answer = max(answer, calc2() - arr[i].at*p);
		}
	}

	printf("%lld", answer);

	fclose(stdin);
	fclose(stdout);

	return 0;
}