#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
int n, m, k, las, ans;
int a[N], b[N], c[N], val[N], E[N], cnt[N];
struct node {
  int w, id;
  node() {}
  node(int _w, int _id) : w(_w), id(_id) {}
  bool operator<(const node &cur) const { return w < cur.w; }
} now;
priority_queue<node> q;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i], E[i] = i;
  while (m--) {
    int u, v;
    cin >> u >> v;
    E[v] = max(E[v], u);
  }
  val[n] = a[n];
  for (int i = n - 1; i >= 1; i--) val[i] = max(a[i], val[i + 1] - b[i]);
  las = k;
  for (int i = 1; i <= n; i++) {
    if (las < a[i]) {
      puts("-1");
      return 0;
    }
    las += b[i];
  }
  las = k;
  for (int i = 1; i <= n; i++) {
    cnt[i] = las + b[i] - val[i + 1];
    las = val[i + 1];
    q.push(node(c[i], i));
  }
  while (!q.empty()) {
    now = q.top();
    q.pop();
    int w = now.w, id = now.id, kk = E[now.id];
    while (!cnt[kk] && kk > 0) kk--;
    if (!kk) continue;
    cnt[kk]--;
    ans += w;
  }
  cout << ans << endl;
  return 0;
}
