#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f, N = 5e3 + 5;
const ll LINF = 1e18 + 5;
int n, m, k, a[N], b[N], c[N], in[N], cur;
int x[N];
vector<int> G[N];
bool tag[N], bad[N][N];
void init() {
  for (int i = n; i >= 1; i--) {
    for (int j : G[i]) {
      if (!tag[j])
        tag[j] = 1;
      else
        bad[i][j] = 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) G[i].push_back(i);
  init();
  cur = k;
  for (int i = 1; i <= n; i++) {
    if (cur < a[i]) {
      cout << -1;
      return 0;
    }
    cur += b[i];
  }
  x[n] = cur;
  int minn = INF;
  for (int i = n; i >= 2; i--) {
    cur -= b[i];
    minn = min(minn, cur - a[i]);
    x[i - 1] = minn;
  }
  set<pii> st;
  for (int i = 1; i <= n; i++) {
    for (int v : G[i])
      if (!bad[i][v]) st.insert({c[v], v});
    while ((int)st.size() > x[i]) {
      auto it = st.begin();
      st.erase(it);
    }
  }
  int val = 0;
  for (auto x : st) val += x.first;
  cout << val;
  return 0;
}
