#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MAXN = 5e3 + 6;
int ans = 0;
int n, m, k, q;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int e[MAXN];
int zap[MAXN];
struct Zm {
  int id;
  bool operator>(const Zm& z) const {
    if (c[id] == c[z.id]) {
      return max(id, e[id]) > max(z.id, e[z.id]);
    } else {
      return c[id] > c[z.id];
    }
  }
};
Zm zam[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = (int)(0); i < (int)(m); ++i) {
    int v, w;
    cin >> v >> w;
    e[w] = max(e[w], v);
  }
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (i >= 2) {
      zap[i - 1] = min(zap[i - 1], k - a[i]);
    }
    if (k - a[i] < 0) {
      cout << "-1\n";
      return 0;
    }
    k += b[i];
    zap[i] = k;
  }
  zam[n].id = n;
  for (int i = (int)(n - 1); i >= (int)(1); --i) {
    zap[i] = min(zap[i], zap[i + 1]);
    zam[i].id = i;
  }
  int mx = 0;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    if (zap[i] <= 0) mx = i;
  }
  sort(zam + 1, zam + n + 1, greater<Zm>());
  for (int i = (int)(1); i <= (int)(n); ++i) {
    int id = zam[i].id;
    int pkt = id;
    if (e[id] != 0) pkt = max(pkt, e[id]);
    if (pkt > mx) {
      ans += c[id];
      for (int j = (int)(pkt); j <= (int)(n); ++j) {
        --zap[j];
        if (zap[j] <= 0) {
          mx = max(j, mx);
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
