#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstdlib>
#include <vector>
#define ll long long
using namespace std;

const int MAXN = 1e5 + 111;

struct CC
{
	int y, b, c;
	CC() {}
	CC(int y, int b, int c) : y(y), b(b), c(c) {}
};

struct XX
{
	int x, a;
	XX() {}
	XX(int x, int a) : x(x), a(a) {}
};

int n, m, p;

vector <pair <int, int> > v;

int k;

XX x[MAXN];

CC c[MAXN], pc[MAXN];

set <CC> st;

bool operator <(CC a, CC b)
{
	return a.c < b.c || (a.c == b.c && a.y < b.y);
}

void solve1()
{
	ll sum = 0, ans = 0;
	for (int i = 0; i < n; i++)
		sum += x[i].a;
	sort(c + 0, c + m);
	for (int i = m - 1; i >= 0; i--)
	{
		if (sum >= c[i].b)
		{
			ans += (ll)c[i].b * c[i].c;
			sum -= c[i].b;
		}
		else
		{
			ans += sum * c[i].c;
			sum = 0;
		}
	}
	cout << ans;
	exit(0);
}

void cop(int m)
{
	for (int i = 0; i < m; i++)
		c[i] = pc[i];
}

ll solve2()
{
	cop(k);
	sort(c + 0, c + k);
	int xx = 0;
	for (int i = 0; i < k; i++)
		xx = max(xx, c[i].y);
	int id = k - 1;
	int cur = 0;
	ll ans = 0;
	ll cc = 0;
	ll sum = 0;
	int ii;
	for (int i = 0; i < n; i++)
	{
		cur = x[i].x;
		sum += x[i].a;
		if (id == -1)
			break;
		while (id >= 0 && sum >= c[id].b)
		{
			cc += (ll)c[id].b * c[id].c;
			sum -= c[id].b;
			c[id].b = 0;
			id--;
		}
		if (id != -1)
		{
			cc += (ll)sum * c[id].c;
			c[id].b -= sum;
			sum = 0;
		}
		if (cc - (ll)max(x[i].x, xx) * p > ans)
		{
			ans = cc - (ll)max(x[i].x, xx) * p;
			ii = i;
		}
	}
	return ans;
}

void solve3()
{
	ll ans = 0;
	for (int i = 1; i <= m; i++)
	{
		k = i;
		ans = max(ans, solve2());
	}
	cout << ans;
}

void solve4()
{
	ll ans = 0;
	ll sum = 0;
	ll vv = 0;
	ll cc = 0;
	for (int i = 0; i < n; i++)
		sum += x[i].a;
	for (int i = 0; i < m; i++)
	{
		st.insert(c[i]);
		vv += c[i].b;
		cc += (ll)c[i].b * c[i].c;
		while (!st.empty())
		{
			CC bb = *st.begin();
			if (vv - bb.b >= sum)
			{
				cc -= (ll)bb.b * bb.c;
				vv -= bb.b;
				st.erase(bb);
			}
			else
				break;
		}
		ll ccc = 0;
		if (!st.empty())
		{
			CC bb = *st.begin();
			if (vv > sum)
				ccc = (vv - sum) * bb.c;
		}
		ans = max(ans, cc - ccc - (ll)c[i].y * p);
	}
	cout << ans;
	exit(0);
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	scanf("%d %d %d", &n, &m, &p);
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &x[i].x, &x[i].a);
		v.push_back(make_pair(0, i));
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d %d", &c[i].y, &c[i].b, &c[i].c);
		v.push_back(make_pair(1, i));
	}
	for (int i = 0; i < m; i++)
		pc[i] = c[i];
	if (p == 0)
		solve1();
	if (c[m - 1].y < x[0].x)
	{
		k = m;
		cout << solve2();
		return 0;
	}
	if (x[n - 1].x < c[0].y)
		solve4();
	solve3();
	return 0;
}