#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stdio.h>
#include <cmath>
#include <map>

using namespace std;

struct tree_node {
	long long price;
	long long his_count;
	long long count;
	long long ans;
	long long prior;
	tree_node *left, *right;
	tree_node(long long new_price, long long new_count) {
		price = new_price;
		his_count = new_count;
		count = new_count;
		ans = price * count;
		left = right = nullptr;
		prior = rand() << 15 + rand();
	}
};

long long get_price(tree_node *root) {
	if (root == nullptr) {
		return 0;
	}
	return root->price;
}

long long get_count(tree_node *root) {
	if (root == nullptr) {
		return 0;
	}
	return root->count;
}

long long get_his_count(tree_node *root) {
	if (root == nullptr) {
		return 0;
	}
	return root->his_count;
}

long long get_ans(tree_node *root) {
	if (root == nullptr) {
		return 0;
	}
	return root->ans;
}

void comb(tree_node *root) {
	root->count = get_count(root->left) + get_count(root->right);
	root->ans = get_ans(root->left) + get_ans(root->right);
}

pair <tree_node*, tree_node*> split(tree_node* root, long long key) {
	if (root == nullptr) {
		return make_pair(nullptr, nullptr);
	}
	if (root->price > key) {
		pair <tree_node*, tree_node*> splitted = split(root->left, key);
		root->left = splitted.second;
		return make_pair(splitted.first, root);
	}
	else {
		pair <tree_node*, tree_node*> splitted = split(root->right, key);
		root->right = splitted.first;
		return make_pair(root, splitted.second);
	}
}

tree_node* merge(tree_node *left, tree_node *right) {
	if (left == nullptr || right == nullptr) {
		return (left == nullptr ? right : left);
	}
	if (right->prior > left->prior) {
		right->left = merge(left, right->left);
		return right;
	}
	else {
		left->right = merge(left->right, right);
		return left;
	}
}

tree_node* insert(tree_node *root, tree_node* val) {
	pair <tree_node*, tree_node*> a = split(root, val->price);
	return merge(merge(a.first, val), a.second);
}

long long max_res(tree_node *root, long long sum) {
	if (sum == 0) return 0;
	if (sum <= get_count(root->right)) {
		return max_res(root->right, sum);
	}
	long long ost = sum - get_count(root->right);
	long long res1 = get_ans(root->right);
	if (ost <= root->his_count) {
		return res1 + ost * root->price;
	}
	else {
		return res1 + root->his_count * root->price + max_res(root->left, ost - root->count);
	}
}

void pront(tree_node *root) {
	if (root == nullptr) return;
	pront(root->left);
	cout << root->price << " ";
	pront(root->right);
}

const long long INF = 10000000000000000;
const long long N = 500001;
long long a[N], x[N], b[N], y[N], c[N];
set <pair <long long, long long> > S;
map <long long, long long> stock;

int main()
{
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	long long n, m, cost;
	cin >> n >> m >> cost;
	for (long long i = 1; i <= n; i++) {
		cin >> x[i] >> a[i];
		S.insert(make_pair(x[i], i));
	}
	for (long long i = 1; i <= m; i++) {
		cin >> y[i] >> b[i] >> c[i];
		S.insert(make_pair(y[i], -i));
	}
	long long sum = 0;
	tree_node *root = new tree_node(0, INF);
	//pront(root);
	//cout << endl;

	long long ans = 0;
	for (auto it = S.begin(); it != S.end(); it++) {
		pair <long long, long long> p = *it;
		if (p.second > 0) {
			sum += a[p.second];
		}
		else {
			tree_node *val = new tree_node(c[-p.second], b[-p.second]);
			root = insert(root, val);
			//pront(root);
			//cout << endl;
		}
		long long res = max_res(root, sum);
		res = res - cost * p.first;
		ans = max(res, ans);
	}
	cout << ans << endl;
	//for (;;);
}

/*

3 2 0
1 5
2 3
4 5
2 2 10
3 6 5

2 1 100
6 5
100 4
5 100 2000

3 3 10
1 1
10 100
20 10
2 1000 1
11 50 50
17 50 2

*/