#include <bits/stdc++.h>
using namespace std;
const int maxn = 5100;
int a[maxn], b[maxn], c[maxn];
int req[maxn], far[maxn], leave[maxn];
int n, m, k;
priority_queue<pair<int, int> > pq;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    far[i] = i;
  }
  for (int i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    far[v] = max(u, far[v]);
  }
  int ck = k;
  for (int i = 1; i <= n; ++i)
    if (ck < a[i]) {
      cout << "-1\n";
      return 0;
    } else {
      ck += b[i];
    }
  for (int i = n; i >= 1; --i) {
    req[i] = max(a[i + 1], req[i + 1] - b[i + 1]);
  }
  ck = k;
  for (int i = 1; i <= n; ++i) {
    ck += b[i];
    leave[i] = ck - req[i];
    ck = req[i];
    pq.push(make_pair(c[i], i));
  }
  int val, ans = 0;
  int u, v;
  while (!pq.empty()) {
    val = pq.top().first;
    v = pq.top().second;
    pq.pop();
    u = far[v];
    while (leave[u] == 0 && u > 0) --u;
    if (u == 0)
      continue;
    else {
      --leave[u];
      ans += val;
    }
  }
  cout << ans << '\n';
  return 0;
}
