#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long p = 1, data = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    data = data * 10 + (ch ^ 48);
    ch = getchar();
  }
  return p * data;
}
inline long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = a * r;
    a = a * a;
    b >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) {
  if (!a || !b) return (!a) ? b : a;
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b)
    x = 1, y = 0;
  else {
    exgcd(b, a % b, y, x);
    y -= x * (a / b);
  }
}
const int mod = 1e9 + 7, maxn = 5e3 + 5;
struct node {
  long long to, w;
  friend bool operator<(node a, node b) { return a.w > b.w; }
};
long long n, m, k, a[maxn], b[maxn], c[maxn], mx[maxn];
map<int, int> mp;
int main() {
  n = read(), m = read(), k = read();
  mp.clear();
  for (int i = 1; i <= n; i++) a[i] = read(), b[i] = read(), c[i] = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    mp[v] = max(mp[v], u);
  }
  for (int i = 1; i <= n; i++) mp[i] = max(mp[i], i);
  long long t = k, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (t < a[i]) {
      puts("-1");
      return 0;
    }
    mx[i] = t - a[i];
    t += b[i];
  }
  mx[n + 1] = b[n] + t;
  for (int i = n; i >= 1; i--) mx[i] = min(mx[i], mx[i + 1]);
  vector<node> v;
  for (int i = 1; i <= n; i++) v.push_back({mp[i] + 1, c[i]});
  sort(v.begin(), v.end());
  for (auto x : v) {
    if (mx[x.to]) {
      int t = mx[x.to];
      for (int i = 2; i <= n + 1; i++)
        if (mx[i] >= t) mx[i]--;
      ans += x.w;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
