#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, i;
  cin >> n >> m >> k;
  vector<int> a(n), b(n), c(n), d(n);
  vector<vector<int>> g(n, vector<int>());
  multiset<int> s;
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[i] = i;
  }
  for (i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    d[v] = max(d[v], u);
  }
  for (i = 0; i < n; i++) g[d[i]].push_back(i);
  for (i = 0; i < n; i++) {
    if (k < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    while ((int)s.size() > k - a[i]) s.erase(s.begin());
    for (int to : g[i]) s.insert(c[to]);
    k += b[i];
  }
  while ((int)s.size() > k) s.erase(s.begin());
  int sum = 0;
  for (int i : s) sum += i;
  cout << sum << endl;
}
