#include <bits/stdc++.h>
using namespace std;
int a[5005], b[5005], c[5005], rst[5005], tcont[5005], que[5005];
pair<int, int> prs[5005];
int main() {
  int i, n, m, k, u, v, qtail = 0, tpoint = 1;
  long long ans = 0;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) {
    tcont[i] = i;
    cin >> a[i] >> b[i] >> c[i];
  }
  while (m--) {
    cin >> u >> v;
    tcont[v] = max(tcont[v], u);
  }
  for (i = 1; i <= n; i++) prs[i] = make_pair(tcont[i], c[i]);
  sort(prs + 1, prs + n + 1);
  for (i = 1; i <= n; i++) {
    while (k < a[i] && qtail) {
      k++;
      ans += que[0];
      pop_heap(que, que + qtail);
      qtail--;
    }
    if (k < a[i]) {
      puts("-1");
      return 0;
    }
    k += b[i];
    while (tpoint <= n && prs[tpoint].first == i) {
      k--;
      ans += prs[tpoint].second;
      que[qtail++] = -prs[tpoint].second;
      push_heap(que, que + qtail);
      tpoint++;
    }
  }
  while (k < 0 && qtail) {
    k++;
    ans += que[0];
    pop_heap(que, que + qtail);
    qtail--;
  }
  cout << ans << endl;
  return 0;
}
