#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> p;
vector<int> a, b, c;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  a.resize(n + 2);
  b.resize(n + 2);
  c.resize(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  p.resize(n + 2);
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    p[x].push_back(y);
  }
  int ans = 0;
  vector<int> extra(n + 2, 0);
  for (int i = 1; i <= n; i++) {
    extra[i] = k - a[i];
    k += b[i];
  }
  extra[n + 1] = k;
  for (int i = n; i > 0; i--) {
    extra[i - 1] = min(extra[i], extra[i - 1]);
  }
  if (extra[0] < 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> taken(n + 2, 0);
  priority_queue<int> mp;
  for (int i = n + 1; i > 0; i--) {
    if (taken[i - 1] == 0) {
      mp.push(c[i - 1]);
      taken[i - 1] = 1;
    }
    for (auto ab : p[i - 1]) {
      if (taken[ab] == 0) {
        taken[ab] = 1;
        mp.push(c[ab]);
      }
    }
    if (extra[i - 1] < extra[i]) {
      for (int j = 0; j < extra[i] - extra[i - 1]; j++) {
        if ((int)mp.size() > 0) {
          ans += mp.top();
          mp.pop();
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
