#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

pair<long long, pair<long long, long long> > a[1000000];


struct item
{
	item *l, *r;
	int c, cnt;
	long long sum, ans;
	int p;
	item()
	{
		c = 0, cnt = 0, sum = 0, ans = 0;
		l = NULL;
		r = NULL;
		p = rand();
	}
};

typedef item * pitem;

void upd(pitem &t)
{
	if (t == NULL)
		return;
	long long sum = t->cnt;
	long long ans = (long long)t->c * t->cnt;
	if (t->l != NULL)
	{
		sum += t->l->sum;
		ans += t->l->ans;
	}
	if (t->r != NULL)
	{
		sum += t->r->sum;
		ans += t->r->ans;
	}
	t->sum = sum;
	t->ans = ans;
}


void split(pitem t, pitem &l, pitem &r, int key)
{
	if (t == NULL)
	{
		l = NULL;
		r = NULL;
		return;
	}
	if (t->c > key or (t->c == key and rand() % 2))
	{
		split(t->r, t->r, r, key);
		upd(t);
		l = t;
	}
	else
	{
		split(t->l, l, t->l, key);
		upd(t);
		r = t;
	}
}

void insert(pitem &t, pitem it)
{
	if (t == NULL)
	{
		t = it;
	}
	else
	{
		if (it->p > t->p or (it->p == t->p and rand() % 2))
		{
			split(t, it->l, it->r, it->c);
			t = it;
		}
		else
		{
			if (it->c > t->c)
				insert(t->l, it);
			else
				insert(t->r, it);
		}
	}
	upd(t);
}

long long getsum(pitem &t)
{
	if (!t)
		return 0;
	return t->sum;
}

long long getans(pitem &t)
{
	if (!t)
		return 0;
	return t->ans;
}

long long ans(pitem &t, long long cnt)
{
	if (cnt == 0)
		return 0;
	if (t == NULL)
		return 0;
	if (getsum(t->l) + t->cnt < cnt)
		return getans(t->l) + (long long)t->c * t->cnt + ans(t->r, cnt - getsum(t->l) - t->cnt);
	if (getsum(t->l) < cnt)
		return getans(t->l) + (cnt - getsum(t->l)) * t->c;
	return ans(t->l, cnt);
}

int main()
{
	srand(time(0));
	freopen("fisher.in", "r", stdin);
	freopen("fisher.out", "w", stdout);
	ios::sync_with_stdio(0);
	long long n, m, p;
	scanf("%lld %lld %lld", &n, &m, &p);
	long long cur = 0, best = 0;
    for (long long i = 0; i < n; i++)
    {
        long long pos, x;
        scanf("%lld %lld", &pos, &x);
        a[i] = {pos, {-1, x}};
    }
    for (long long i = 0; i < m; i++)
    {
        long long pos, x, b;
        scanf("%lld %lld %lld", &pos, &x, &b);
        a[i + n] = {pos, {x, b}};
    }
	sort(a, a + n + m);
	long long pos = 0;
	pitem root = NULL;
	long long tecsum = 0;
	for (long long i = 0; i < n + m; i++)
	{
		cur -= p * (a[i].first - pos);
		pos = a[i].first;
		if (a[i].second.first == -1)
		{
			tecsum += a[i].second.second;
		}
		else
		{
			pitem it = new item();
			it->c = a[i].second.second;
			it->cnt = a[i].second.first;
			if (!(it->c == 0 or it->cnt == 0))
				insert(root, it);
		}
		best = max(best, ans(root, tecsum) + cur);
	}
	printf("%lld", best);
}
