#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <memory.h>

using namespace std;

//#define int long long
#define sz(a) (int)(a.size())

struct fish
{
	int x, cnt;
};

struct shop
{
	int x, cnt, cost;
};

int n, m, p;
const int MAXN = 1e6 + 10;
fish a[MAXN];
shop b[MAXN];
long long z[MAXN];
long long z2[MAXN];
int deg2[30];

void add(int pos, int d)
{
	for (int i = pos; i < MAXN; i = (i | (i + 1)))
		z[i] += d;
}

long long get(int pos)
{
	if (pos < 0)
		return 0;
	long long res = 0;
	for (int i = pos; i >= 0; i = (i & (i + 1)) - 1)
	{
		res += z[i];
	}
	return res;
}

long long get(int l, int r)
{
	if (l > r)
		return 0;
	return get(r) - get(l - 1);
}

void add2(int pos, int d)
{
	for (int i = pos; i < MAXN; i = (i | (i + 1)))
		z2[i] += d;
}

long long get2(int pos)
{
	if (pos < 0)
		return 0;
	long long res = 0;
	for (int i = pos; i >= 0; i = (i & (i + 1)) - 1)
	{
		res += z2[i];
	}
	return res;
}

long long get2(int l, int r)
{
	if (l > r)
		return 0;
	return get2(r) - get2(l - 1);
}

signed main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	cin >> n >> m >> p;
	deg2[0] = 1;
	for (int i = 1; i < 30; ++i)
	{
		deg2[i] = (deg2[i - 1] << 1);
	}
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].x >> a[i].cnt;
	}
	for (int i = 1; i <= m; ++i)
	{
		cin >> b[i].x >> b[i].cnt >> b[i].cost;
	}
	vector<int> cord;
	for (int i = 1; i <= m; ++i)
	{
		cord.push_back(b[i].x);
	}
	for (int i = 1; i <= n; ++i)
	{
		cord.push_back(a[i].x);
	}
	sort(cord.begin(), cord.end());
	int ka = 0, kb = 0;
	long long sum = 0;
	long long ans = 0;
	int maxx = 0;
	for (int i = 0; i < sz(cord); ++i)
	{
		int x = cord[i];
		while (ka + 1 <= n && a[ka + 1].x <= x)
		{
			++ka;
			sum += a[ka].cnt;
		}
		while (kb + 1 <= m && b[kb + 1].x <= x)
		{
			++kb;
			add(b[kb].cost, b[kb].cnt);
			add2(b[kb].cost, b[kb].cost * b[kb].cnt);
			maxx = max(maxx, b[kb].cost);
		}
		int r = maxx;
		int l = maxx;
		for (int j = 29; j >= 0; --j)
		{
			if (get(max(0, l - deg2[j]), r) <= sum)
			{
				l = max(0, l - deg2[j]);
			}
		}
		while (get(l, r) > sum)
		{
			++l;
		}
		long long tmp = sum - get(l, r);
		long long cur = get2(l, r) - x * p;
		if (tmp > 0 && l > 0)
		{
			cur += (l - 1) * tmp;
		}
		ans = max(ans, cur);
	}
	cout << ans;
	return 0;
}