#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];
int z[MAXN];
int z2[MAXN];

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

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

int 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;
}

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

int 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;
	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;
	}
	if (p == 0)
	{
		long long sum = 0;
		for (int i = 1; i <= n; ++i)
		{
			sum += a[i].cnt;
		}
		auto cmp = [](shop a, shop b) { return a.cost > b.cost; };
		sort(b + 1, b + m + 1, cmp);
		long long ans = 0;
		for (int i = 1; i <= m; ++i)
		{
			int t = min(sum, 1LL * b[i].cnt);
			sum -= t;
			ans += t * b[i].cost;
		}
		cout << ans;
		return 0;
	}
	else if (b[m].x <= a[1].x)
	{
		int top = 0;
		int sum = 0;
		auto cmp = [](shop a, shop b) { return a.cost > b.cost; };
		sort(b + 1, b + m + 1, cmp);
		int ans = 0;
		a[0].x = 0;
		int ptr = 1;
		int cur = 0;
		for (int i = 1; i <= n; ++i)
		{
			top = (a[i].x - a[i - 1].x) * p;
			sum += a[i].cnt;
			cur -= top;
			for (int j = ptr; j <= m; ++j)
			{
				int t = min(sum, b[j].cnt);
				sum -= t;
				b[j].cnt -= t;
				cur += t * b[j].cost;
				if (sum == 0)
				{
					ptr = j;
					break;
				}
			}
			if (b[m].cnt == 0)
				ptr = m + 1;
			ans = max(ans, cur);
		}
		cout << ans;
		return 0;
	}
	else
	{
		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;
		int sum = 0;
		int 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;
			while (l > 0 && get(l, r) <= sum)
			{
				--l;
			}
			++l;
			int tmp = sum - get(l, r);
			int cur = get2(l, r) - x * p;
			if (tmp > 0 && l > 0)
			{
				cur += (l - 1) * tmp;
			}
			ans = max(ans, cur);
		}
		cout << ans;
	}
	return 0;
}