#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
int w[N];
int a[N];
int b[N];
pair<int, int> c[N];
int Max[N];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i].first;
  }
  for (int i = 0; i < n; i++) {
    Max[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    Max[v - 1] = max(Max[v - 1], u - 1);
  }
  for (int i = 0; i < n; i++) {
    c[i].second = Max[i];
  }
  sort(c, c + n);
  for (int i = 0; i < n; i++) {
    if (k < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    w[i] = k - a[i];
    k += b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    w[i] = w[i + 1];
  }
  for (int i = n - 2; i >= 0; i--) {
    w[i] = min(w[i + 1], w[i]);
  }
  w[n - 1] = k;
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (w[c[i].second] > 0) {
      for (int j = c[i].second; j < n; j++) {
        w[j]--;
      }
      for (int j = n - 2; j >= 0; j--) {
        w[j] = min(w[j + 1], w[j]);
      }
      ans += c[i].first;
    }
  }
  cout << ans << endl;
}
