#include <bits/stdc++.h>
using namespace std;
bool compare(long long int a, long long int b) { return a > b; }
unsigned seed = chrono::steady_clock::now().time_since_epoch().count();
long long int modexp(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y % 2) res = res * x % 998244353;
    x = x * x % 998244353;
    y /= 2;
  }
  return res;
}
long long int modinv(long long int x) { return modexp(x, 998244353 - 2); }
long long int gcd(long long int x, long long int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m, k;
  cin >> n >> m >> k;
  vector<long long int> a(n), b(n), c(n);
  for (long long int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  vector<long long int> f(n, 0);
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    u--;
    v--;
    f[v] = max(f[v], u);
  }
  vector<long long int> port[n];
  for (long long int i = 0; i < n; i++) {
    if (f[i] == 0)
      port[i].push_back(i);
    else
      port[f[i]].push_back(i);
  }
  multiset<long long int> s;
  long long int fl = 0;
  long long int w = k;
  for (long long int i = 0; i < n; i++) {
    while (w < a[i] && !s.empty()) {
      long long int x = *s.begin();
      s.erase(s.find(x));
      w++;
    }
    if (w < a[i]) {
      fl = 1;
      break;
    }
    w += b[i];
    for (long long int j = 0; j < port[i].size(); j++) {
      s.insert(c[port[i][j]]);
      w--;
    }
  }
  while (w < 0 && !s.empty()) {
    long long int x = *s.begin();
    s.erase(s.find(x));
    w++;
  }
  if (w < 0) fl = 1;
  if (fl) {
    cout << -1 << "\n";
    return 0;
  }
  long long int sum = 0;
  for (auto x : s) sum += x;
  cout << sum << "\n";
}
