#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 5e5 + 5;
int n, m;
long long p, x[MAXN], y[MAXN], a[MAXN];
// b[MAXN], c[MAXN];
pair <long long, long long> bc[MAXN];

int main()
{
  freopen("fisher.in", "r", stdin);
  freopen("fisher.out", "w", stdout);
  cin >> n >> m >> p;
  long long sumt = 0, ans = 0, res = 0;

  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> a[i];
    sumt += a[i];
  }

  for (int i = 0; i < m; i++)
  {
    cin >> y[i] >> bc[i].second >> bc[i].first; 
  }

  if (p == 0)
  {
    sort(bc, bc + m);
    int i = m - 1; 
    while (i >= 0 && sumt != 0)
    {
      ans += min(sumt, bc[i].second) * bc[i].first;
      sumt -= min(sumt, bc[i].second);
      i--;
    }

    cout << ans;
    return 0;
  }  
  if (y[m - 1] < x[0])
  {
    long long sumt = 0;
    int id = m - 1;
    sort(bc, bc + m);

    for (int i = 0; i < n; i++)
    {      
      sumt += a[i];
      res -= x[i] * p;
      
      while (id >= 0 && sumt > 0)
      {
        ans += min(sumt, bc[id].second) * bc[id].first;
        sumt -= min(sumt, bc[id].second);
        id--; 
      }

      ans = max(ans, res);
    }

    cout << ans;
    return 0;
  } 

  
  return 0;
}


