#pragma comment(linker, "/Stack:512000000")
#define	_CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long LL;
typedef double dbl;

#define all(x) (x).begin(), (x).end()

const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const dbl EPS = 1e-9;

LL nextRand() {
  if (RAND_MAX < 40000)
    return ((rand() * 1ll) << 15) + rand();
  else
    return rand();
}

struct ST {
  int L, R;
  LL sumfish, sum;
  int b, c;

  ST *left, *right;

  ST(int L, int R, const vector<pair<int, int>> &a) : L(L), R(R) {
    left = right = nullptr;
    if (L == R) {
      b = a[L].second;
      c = a[L].first;
      sumfish = sum = 0;
    }
    else {
      int mid = (L + R) / 2;
      left = new ST(L, mid, a);
      right = new ST(mid + 1, R, a);
      sum = sumfish = 0;
    }
  }

};

void update(ST *root) {
  if (root == nullptr) return;
  if (root->L == root->R) return;
  root->sum = root->left->sum + root->right->sum;
  root->sumfish = root->left->sumfish + root->right->sumfish;
}

void qenable(ST *root, int id) {
  if (root == nullptr) return;
  if (root->L == root->R) {
    root->sum = root->b * 1ll * root->c;
    root->sumfish = root->b;
    return;
  }
  int mid = (root->L + root->R) / 2;
  if (id <= mid)
    qenable(root->left, id);
  else
    qenable(root->right, id);
  update(root);
}

LL qget(ST *root, LL sum) {
  if (root == nullptr || sum < 1) return 0;

  if (root->sumfish <= sum) {
    return root->sum;
  }

  if (root->L == root->R)
    return root->c * 1ll * min(root->b * 1ll, sum);

  LL ans = qget(root->right, sum) + qget(root->left, sum - root->right->sumfish);
  return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#elif 1
#define PROB "fisher"
	freopen(PROB".in", "r", stdin);
	freopen(PROB".out", "w", stdout);
#endif
  int n, m, p;
  scanf("%d %d %d\n", &n, &m, &p);

  struct Event {
    LL pos, type, a, b, c;

    bool operator<(const Event &e) {
      return pos != e.pos ? pos < e.pos : type != e.type ? type < e.type : a < e.a;
    }
  };

  LL ans = 0;

  vector<Event> events;

  for (int i = 0; i < n; ++i) {
    int x, a;
    scanf("%d%d", &x, &a);

    Event tmp{ x, 0, a, 0, 0 };
    events.push_back(tmp);
  }

  vector<pair<pair<int, int>, pair<int, int>>> buy;

  for (int i = 0; i < m; ++i) {
    int y, b, c;
    scanf("%d %d %d", &y, &b, &c);
    buy.push_back({ { c, b }, {y, i} });
  }

  sort(all(buy));
  vector<pair<int, int>> bubu(m);

  for (int i = 0; i < m; ++i) {
    auto f = buy[i].first, s = buy[i].second;
    Event tmp{ s.first, 1, i, f.second, f.first };
    bubu[i] = f;
    events.push_back(tmp);
  }

  ST *root = new ST(0, m - 1, bubu);

  //events.push_back(Event{0, 1, 0, INF * 1ll * INF, 0});

  sort(all(events));

  LL sumfish = 0;

  for (auto e : events) {
    if (e.type == 0) {
      sumfish += e.a;
      ans = max(ans, qget(root, sumfish) - e.pos * 1ll * p);
    }
    else {
      qenable(root, e.a);
      ans = max(ans, qget(root, sumfish) - e.pos * 1ll * p);
    }
  }

  cout << ans << endl;

	return 0;
}