
#include <iostream>
#include <vector>
#include <algorithm>

#pragma comment (linker, "/STACK:100000000")

using namespace std;

struct Fish
{
	long long coord;
	long long amount;
};

struct Base
{
	long long coord;
	long long cap;
	long long cost;
	int       index;

	bool operator < (const Base& that) const
	{
		return (cost > that.cost);
	}
};

void solve_fuel0     (vector <Fish>& fish, vector <Base>& base);
void solve_base_fish (vector <Fish>& fish, vector <Base>& base, long long fuel);
void solve_fish_base (vector <Fish>& fish, vector <Base>& base, long long fuel);

int main ()
{
	freopen ( "fisher.in", "r", stdin);
	freopen ("fisher.out", "w", stdout);

	int n_fish = 0, n_base = 0;
	long long fuel = 0;
	cin >> n_fish >> n_base >> fuel;

	vector <Fish> fish (n_fish);
	vector <Base> base (n_base);

	for (int i = 0; i < n_fish; i++)
		cin >> fish[i].coord >> fish[i].amount;

	for (int i = 0; i < n_base; i++)
	{
		cin >> base[i].coord >> base[i].cap >> base[i].cost;
		base[i].index = i;
	}

	if (fuel == 0)
	{
		solve_fuel0 (fish, base);
	}
	else if(base[n_base - 1].coord < fish[0].coord)
	{
		solve_base_fish (fish, base, fuel);
	}
	else if(fish[n_fish - 1].coord < base[0].coord)
	{
		solve_fish_base (fish, base, fuel);
	}

	return 0;
}

void solve_fuel0 (vector<Fish>& fish, vector<Base>& base)
{
	sort (base.begin (), base.end ());
	long long all_caught = 0;

	for (int i = 0; i < int (fish.size ()); i++)
		all_caught += fish[i].amount;

	long long all_cost = 0;

	for(int i = 0; i < int (base.size ()); i++)
	{
		if (base[i].cap <= all_caught)
		{
			all_cost += (base[i].cap * base[i].cost);
			all_caught -= base[i].cap;
		}
		else
		{
			all_cost += (all_caught * base[i].cost);
			break;
		}
	}

	cout << all_cost << "\n";
}

void solve_base_fish (vector <Fish>& fish, vector <Base>& base, long long fuel)
{
	sort (base.begin (), base.end ());

	long long curr_max   = 0;
	long long all_caught = 0;

	int                 ptr = 0;
	long long curr_can_sell = 0;
	long long curr_profit   = 0;

	for(int i = 0; i < int (fish.size ()); i++)
	{
		all_caught += fish[i].amount;

		while (ptr < base.size () && curr_can_sell + base[ptr].cap <= all_caught)
		{
			curr_can_sell += base[ptr].cap;
			curr_profit   += base[ptr].cap * base[ptr].cost;

			ptr++;
		}

		if (ptr < base.size ())
		{
			long long new_profit = curr_profit +
				                   (all_caught - curr_can_sell) * base[ptr].cost -
				                   fish[i].coord * fuel;

			if (new_profit > curr_max)
				curr_max = new_profit;
		}
		else
		{
			long long new_profit = curr_profit - fish[i].coord * fuel;
			
			if (new_profit > curr_max)
				curr_max = new_profit;
		}
	}

	cout << curr_max << "\n";
}

void solve_fish_base (vector <Fish>& fish, vector <Base>& base, long long fuel)
{
	long long all_caught = 0;

	for (int i = 0; i < int (fish.size ()); i++)
		all_caught += fish[i].amount;

	sort (base.begin (), base.end ());

	vector <int> sorted_ind (base.size ());

	for (int i = 0; i < int (base.size ()); i++)
		sorted_ind [base[i].index] = i;

	vector <bool> available (base.size (), true);
	int ptr = 0;
	
	long long curr_profit = 0;
	long long curr_sold   = 0;

	vector <int> got (base.size ());

	while (ptr < base.size () && curr_sold + base[ptr].cap <= all_caught)
	{
		curr_sold += base[ptr].cap;
		curr_profit += base[ptr].cap * base[ptr].cost;
		
		got [ptr] = base[ptr].cap;
		ptr++;
	}

	if(ptr < base.size ())
	{
		curr_profit += base[ptr].cost * (all_caught - curr_sold);
		got [ptr] = all_caught - curr_sold;
		curr_sold = all_caught;
	}

	long long curr_max = curr_profit - base.back().coord * fuel;

	for(int i = int (base.size ()) - 1; i >= 0; i--)
	{
		int out = sorted_ind [i];
		available [out] = false;

		if (out <= ptr)
		{
			curr_sold   -= got [out];
			curr_profit -= got [out] * base[out].cost;
		}

		while(ptr < base.size () && curr_sold + (base[ptr].cap - got [ptr]) <= all_caught)
		{
			if (!available [ptr])
			{
				ptr++;
				continue;
			}

			curr_sold   += (base[ptr].cap - got [ptr]);
			curr_profit += (base[ptr].cap - got [ptr]) * base[ptr].cost;
		
			got [ptr] = base[ptr].cap;
			ptr++;
		}

		if(ptr < base.size () && available [ptr])
		{
			curr_profit += base[ptr].cost * (all_caught - curr_sold);
			got [ptr] += all_caught - curr_sold;
			curr_sold = all_caught;
		}

		long long new_profit = curr_profit - base[i].coord;

		curr_max = max (curr_max, new_profit);
	}

	cout << curr_max << "\n";
}