#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int A[MAXN], B[MAXN], C[MAXN], KK[MAXN], RY[MAXN], Latest[MAXN];
vector<int> G[MAXN];
int inq[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m >> KK[0];
  for (int i = 0; i < n; i++) {
    cin >> A[i] >> B[i] >> C[i];
    Latest[i] = i;
  }
  int f = 1;
  for (int i = 0; i < n; i++) {
    if (KK[i] < A[i]) {
      f = 0;
      break;
    }
    KK[i + 1] = KK[i] + B[i];
  }
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    Latest[v - 1] = max(Latest[v - 1], u - 1);
  }
  for (int i = 0; i < n; i++) G[Latest[i]].push_back(i);
  if (!f) {
    cout << -1 << endl;
  } else {
    RY[n - 1] = KK[n];
    for (int i = n - 2; i >= 0; i--) {
      RY[i] = min(RY[i + 1], KK[i + 1] - A[i + 1]);
    }
    priority_queue<pair<int, int>, vector<pair<int, int> >,
                   greater<pair<int, int> > >
        Q;
    for (int u = 0; u < n; u++) {
      for (auto v : G[u]) {
        if (!inq[v]) {
          inq[v] = 1;
          Q.push({C[v], v});
        }
      }
      while (Q.size() > RY[u]) {
        inq[Q.top().second] = 0;
        Q.pop();
      }
    }
    int ans = 0;
    while (!Q.empty()) {
      ans += Q.top().first;
      Q.pop();
    }
    cout << ans << endl;
  }
}
