#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <random>
#include <time.h>

using namespace std;

#define SIZE 500228
#define ll long long
#define pint pair<int, int>
#define mp make_pair

struct Node
{
	ll key, mon, cntf;
	int prior;
	ll b, c;
	Node *l, *r;
	Node() : l(nullptr), r(nullptr) {}
	Node(ll b, ll c, int prior) : b(b), c(c), key(b * c), prior(prior), l(nullptr), r(nullptr), cntf(b), mon(b * c) {}
};

#define PNode Node*

Node k[SIZE * 2];
int sz = 0;

PNode root;

ll get(PNode root)
{
	if (!root)
		return 0;
	return root->mon;
}

ll getf(PNode root)
{
	if (!root)
		return 0;
	return root->cntf;
}

void update(PNode &root)
{
	if (root)
	{
		root->mon = get(root->l) + get(root->r) + root->key;
		root->cntf = getf(root->l) + getf(root->r) + root->b;
	}
}

void Split(PNode root, PNode &l, PNode &r, ll x)
{
	if (!root)
		return void(l = r = nullptr);
	if (root->c >= x)
	{
		Split(root->r, root->r, r, x);
		l = root;
		update(l);
	}
	else
	{
		Split(root->l, l, root->l, x);
		r = root;
		update(r);
	}
}

void Insert(PNode &root, PNode in)
{
	if (!root)
		root = in;
	else if (in->prior > root->prior)
	{
		Split(root, in->l, in->r, in->c);
		root = in;
	}
	else
		Insert(root->c >= in->c ? root->r : root->l, in);
	update(root);
}

ll gt(PNode root, ll fish)
{
	if (!root)
		return 0;
	if (getf(root->l) >= fish)
		return gt(root->l, fish);
	if (getf(root->l) + root->b >= fish)
		return get(root->l) + (fish - getf(root->l)) * root->c;
	return get(root->l) + root->key + gt(root->r, fish - getf(root->l) - root->b);
}

struct Fish
{
	ll x, a;
	Fish() {}
};

struct Base
{
	ll y, b, c;
	Base() {}
};

int n, m, p;
Fish a[SIZE];
Base b[SIZE];
int it1 = 0, it2 = 0;
ll ans = 0;
ll dist = 0;
ll summ = 0;

void add(int pos, int f)
{
	if (f == 1)
	{
		dist = a[pos].x;
		summ += a[pos].a;
		ll ret = summ < getf(root) ? gt(root, summ) - dist * p : get(root) - dist * p;
		ans = max(ans, ret);
	}
	else
	{
		dist = b[pos].y;
		//Node(ll b, ll c, int prior) : b(b), c(c), key(b * c), prior(prior), l(nullptr), r(nullptr), cntf(b), mon(b * c) {}
		k[sz].b = b[pos].b;
		k[sz].c = b[pos].c;
		k[sz].cntf = b[pos].b;
		k[sz].key = b[pos].b * b[pos].c;
		k[sz].l = nullptr;
		k[sz].mon = k[sz].key;
		k[sz].prior = rand();
		k[sz].r = nullptr;
		Insert(root, &k[sz]);
		sz++;
		ll ret = summ < getf(root) ? gt(root, summ) - dist * p : get(root) - dist * p;
		ans = max(ans, ret);
	}
}

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m >> p;
	for (int i = 0; i < n; i++)
		cin >> a[i].x >> a[i].a;
	for (int i = 0; i < m; i++)
		cin >> b[i].y >> b[i].b >> b[i].c;
	while (it1 < n || it2 < m)
	{
		if (it1 == n)
		{
			add(it2, 2);
			it2++;
		}
		else if (it2 == m)
		{
			add(it1, 1);
			it1++;
		}
		else if (a[it1].x < b[it2].y)
		{
			add(it1, 1);
			it1++;
		}
		else
		{
			add(it2, 2);
			it2++;
		}
	}
	cout << ans << endl;
	return 0;
}