#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef int ll;
typedef int my_int;

const int MAXN = (int)5e5 + 47;

int n, m, p;

struct Fish
{
	int x, a;
};

struct Shop
{
	int x, b, c;
};

enum { FISH, SHOP };

struct Event
{
	int x, type, id;
	Event(int x, int type, int id) : x(x), type(type), id(id) {}
};

pair < ll, ll > t[4 * MAXN];

vector < Fish > ff;
vector < Shop > ss;

vector < Event > ee;

void input()
{
	//scanf("%d %d %d", &n, &m, &p);
	cin >> n >> m >> p;
	ff.resize(n);
	ss.resize(m);
	for (int i = 0; i < n; i++)
		cin >> ff[i].x >> ff[i].a;
		//scanf("%d %d", &ff[i].x, &ff[i].a);
	for (int i = 0; i < m; i++)
		cin >> ss[i].x >> ss[i].b >> ss[i].c;
		//scanf("%d %d %d", &ss[i].x, &ss[i].b, &ss[i].c);
}

void out(ll ans)
{
	cout << ans;
	exit(0);
}

bool cmpSS(const Shop &a, const Shop &b)
{
	return a.c > b.c || (a.c == b.c && a.b > b.b);
}

bool cmpFF(const Fish &a, const Fish &b)
{
	return a.x < b.x;
}

bool cmpEE(const Event &a, const Event &b)
{
	return a.x < b.x || (a.x == b.x && a.type < b.type);
}

void update(int v, int l, int r, int pos, ll b, ll c)
{
	if (r - l == 1)
	{
		t[v].first = b;
		t[v].second = b * 1LL * c;
		return;
	}
	int mid = (l + r) / 2;
	if (pos < mid)
		update(2 * v + 1, l, mid, pos, b, c);
	else
		update(2 * v + 2, mid, r, pos, b, c);
	t[v].first = t[2 * v + 1].first + t[2 * v + 2].first;
	t[v].second = t[2 * v + 1].second + t[2 * v + 2].second;
}

pair < ll, ll > query(int v, int l, int r, int ql, int qr)
{
	if (ql <= l && r <= qr)
		return t[v];
	if (ql >= r || qr <= l)
		return{ 0, 0 };
	int mid = (l + r) / 2;
	pair < ll, ll > a, b;
	a = query(2 * v + 1, l, mid, ql, qr);
	b = query(2 * v + 2, mid, r, ql, qr);
	return{ a.first + b.first, a.second + b.second };
};

ll relax(ll sum_fish)
{
	int l = -1, r = m - 1, mid;
	pair < ll, ll > pp = {0, 0};
	while (r - l > 1)
	{
		mid = (l + r) / 2;
		pp = query(0, 0, m, 0, mid);
		if (pp.first >= sum_fish)
			r = mid;
		else
			l = mid;
	}
	if (t[0].first <= sum_fish)
		return t[0].second;
	if (r != 0)
		pp = query(0, 0, m, 0, r);
	if (query(0, 0, m, 0, r + 1).first >= sum_fish)
	{
		ll kk = min(sum_fish - pp.first, (ll)ss[r].b);
		pp.first += kk;
		pp.second += ss[r].c * kk;
	}
	return pp.second;
}

my_int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	input();
	sort(ss.begin(), ss.end(), cmpSS);
	for (int i = 0; i < m; i++)
		ee.push_back(Event(ss[i].x, SHOP, i));
	//sort(ff.begin(), ff.end(), cmpFF);
	for (int i = 0; i < n; i++)
		ee.push_back(Event(ff[i].x, FISH, i));
	sort(ee.begin(), ee.end(), cmpEE);
	int id;
	ll sum_fish = 0, ans = 0;
	for (int i = 0; i < (int)ee.size(); i++)
	{
		id = ee[i].id;
		if (ee[i].type == SHOP)
			update(0, 0, m, id, ss[id].b, ss[id].c);
		else
			sum_fish += ff[id].a;
		ans = max(ans, relax(sum_fish) - ee[i].x * (ll)p);
	}
	out(ans);
	return 0;
}