//#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>

using namespace std;

ifstream cin("fisher.in");
ofstream cout("fisher.out");

typedef long long ll;

struct tNode {
	ll b, c, sum_b, sum_cost;
	int key, size;
	tNode *l, *r;
	tNode(int b_init, int c_init) {
		sum_b = b = b_init;
		c = c_init;
		sum_cost = b * c;
		key = rand();
		size = 1;
		l = r = NULL;
	}
};

typedef tNode *treap;

ll get_c(treap t) {
	return t ? t->c : 0;
}

ll get_sum_b(treap t) {
	return t ? t->sum_b : 0;
}

ll get_sum_cost(treap t) {
	return t ? t->sum_cost : 0;
}

int get_size(treap t) {
	return t ? t->size : 0;
}

void update(treap t) {
	t->sum_b = t->b + get_sum_b(t->l) + get_sum_b(t->r);
	t->sum_cost = t->b * t->c + get_sum_cost(t->l) + get_sum_cost(t->r);
	t->size = 1 + get_size(t->l) + get_size(t->r);
}

treap merge(treap l, treap r) {
	if (!l || !r)
		return l ? l : r;
	treap t;
	if (l->key > r->key)
		l->r = merge(l->r, r), t = l;
	else
		r->l = merge(l, r->l), t = r;
	update(t);
	return t;
}

void split_c(treap root, treap & l, treap & r, ll c) {
	if (!root)
		return void(l = r = NULL);
	if (root->c <= c)
		l = root, split_c(l->r, l->r, r, c);
	else
		r = root, split_c(r->l, l, r->l, c);
	update(root);
}

void split_sum_b(treap root, treap & l, treap & r, ll sum_b) {
	if (!root)
		return void(l = r = NULL);
	ll r_sum_b = get_sum_b(root->r) + root->b;
	if (r_sum_b <= sum_b) {
		r = root;
		split_sum_b(r->l, l, r->l, sum_b - r_sum_b);
		update(r);
		return;
	}
	if (get_sum_b(root->r) >= sum_b) {
		l = root;
		split_sum_b(l->r, l->r, r, sum_b);
		update(l);
		return;
	}
	r = root;
	l = r->l;
	r->l = NULL;
	update(r);
}

void split_size(treap root, treap & l, treap & r, int size) {
	if (!root)
		return void(l = r = NULL);
	int l_size = get_size(root->l) + 1;
	if (l_size <= size)
		l = root, split_size(l->r, l->r, r, size - l_size);
	else
		r = root, split_size(r->l, l, r->l, size);
	update(root);
}

struct fish {
	int x, a;
};

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

const int MAXN = 5e5;
int n, m;
ll p, cur_f, cur_x, ans = 0;
fish f[MAXN];
shop s[MAXN];
treap root;

ll max(ll l, ll r) {
	return l > r ? l : r;
}

ll min(ll l, ll r) {
	return l < r ? l : r;
}

void check_ans() {
	treap l, mid, r;
	split_sum_b(root, l, r, cur_f);
	split_size(r, mid, r, 1);
	ll cur_ans = get_sum_cost(r);
	cur_ans += min(get_sum_b(mid), cur_f - get_sum_b(r)) * get_c(mid);
	cur_ans -= p * cur_x;
	//cout << "X: " << cur_x << ' ' << "FISH: " << cur_f << ' ' << cur_ans << endl;
	//cout << "AND " << get_sum_b(mid) << ' ' << get_sum_b(r) << endl;
	ans = max(ans, cur_ans);
	root = merge(l, mid);
	root = merge(root, r);
}

int main() {
	ios_base::sync_with_stdio(false);
	srand(time(0));
	cin >> n >> m >> p;
	for (int i = 0; i < n; ++i)
		cin >> f[i].x >> f[i].a;
	for (int i = 0; i < m; ++i)
		cin >> s[i].x >> s[i].b >> s[i].c;
	for (int i = 0, j = 0; i < n || j < m;)
		if (i < n && (j == m || f[i].x < s[j].x)) {
			cur_x = f[i].x;
			cur_f += f[i].a;
			check_ans();
			++i;
		} else {
			cur_x = s[j].x;
			treap l, r, t = new tNode(s[j].b, s[j].c);
			split_c(root, l, r, s[j].c);
			root = merge(l, t);
			root = merge(root, r);
			check_ans();
			++j;
		}
	cout << ans << endl;
	return 0;
}