#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n, m, k;
int u, v;
int a[maxn], b[maxn], c[maxn], la[maxn];
vector<int> E[maxn];
priority_queue<int, vector<int>, greater<int> > q;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    la[i] = i;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    la[v] = max(la[v], u);
  }
  for (int i = 1; i <= n; ++i) {
    E[la[i]].push_back(i);
  }
  int kk = k;
  for (int i = 1; i <= n; ++i) {
    if (kk < a[i]) {
      return cout << "-1", 0;
    }
    kk += b[i];
  }
  for (int i = 1; i <= n; ++i) {
    while (k < a[i]) {
      ++k;
      q.pop();
    }
    k += b[i];
    for (auto v : E[i]) {
      --k;
      q.push(c[v]);
    }
  }
  while (k < 0) {
    ++k;
    q.pop();
  }
  int ans = 0;
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }
  printf("%d", ans);
  return 0;
}
