#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<int> > C(N, vector<int>(3));
  vector<vector<int> > Adj(N);
  int i, j;
  for (i = 0; i < N; i++) {
    cin >> C[i][0] >> C[i][1] >> C[i][2];
  }
  for (i = 0; i < M; i++) {
    int U, V;
    cin >> U >> V;
    U--;
    V--;
    Adj[U].push_back(V);
  }
  vector<int> W;
  for (i = 0; i < N; i++) {
    if (K < C[i][0]) {
      cout << -1 << endl;
      return 0;
    } else {
      K += C[i][1];
      if (i != N - 1) {
        W.push_back(K - C[(i + 1)][0]);
      }
    }
  }
  W.push_back(K);
  int Can = (W[(N - 1)]) ? -1 : (N - 1);
  for (i = (N - 2); i >= 0; i--) {
    W[i] = min(W[i], W[(i + 1)]);
    if (W[i] == 0) {
      Can = max(Can, i);
    }
  }
  priority_queue<pair<int, int> > PQ;
  for (i = 0; i < N; i++) {
    PQ.push(make_pair(C[i][2], ((i << 16) + i)));
    for (auto it : Adj[i]) {
      PQ.push(make_pair(C[it][2], ((i << 16) + it)));
    }
  }
  unordered_set<int> Set;
  int Result = 0;
  while (PQ.size()) {
    int Importance = PQ.top().first;
    int From = (PQ.top().second >> 16);
    int To = (PQ.top().second & 0xFFFF);
    PQ.pop();
    if (Set.count(To) == 0) {
      if (From > Can) {
        for (i = From; i < N; i++) {
          W[i]--;
          if (W[i] == 0) {
            Can = i;
          }
        }
        Result += Importance;
        Set.insert(To);
      }
    }
  }
  cout << Result << endl;
  return 0;
}
