#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  vector<int> adj[n];
  int fn[n];
  memset(fn, -1, sizeof(fn));
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    fn[y] = max(fn[y], x);
  }
  for (int i = 0; i < n; i++) {
    if (fn[i] == -1) fn[i] = i;
    adj[i].push_back(i);
  }
  priority_queue<int, vector<int>, greater<int>> mst;
  int cur = k;
  long long int ans = 0, fl = 0;
  for (int i = 0; i < n; i++) {
    if (cur >= a[i])
      cur += b[i];
    else {
      int diff = a[i] - cur;
      while (diff--) {
        if (mst.empty()) {
          fl = 1;
          break;
        }
        int x = mst.top();
        mst.pop();
        ans -= x;
      }
      cur = a[i] + b[i];
    }
    if (fl) break;
    for (int j = 0; j < adj[i].size(); j++) {
      if (fn[adj[i][j]] != i) continue;
      if (cur) {
        cur--;
        mst.push(c[adj[i][j]]);
        ans += c[adj[i][j]];
      } else {
        if (mst.empty()) continue;
        int x = mst.top();
        if (c[adj[i][j]] > x) {
          mst.pop();
          ans -= x;
          mst.push(c[adj[i][j]]);
          ans += c[adj[i][j]];
        }
      }
    }
  }
  if (fl)
    cout << "-1\n";
  else
    cout << ans << "\n";
  return 0;
}
