#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using pairll = pair<ll, ll>;
bool great(pairll a, pairll b) { return a.first > b.first; }
int main() {
  ll n, m, k, a, b, c, x, y, sum = 0, cnt = 0, cash = 0;
  bool bad = 0;
  vll last, army;
  vector<pairll> value;
  cin >> n >> m >> k;
  sum = k;
  for (ll i = 0; i < n; i++) {
    last.push_back(i);
  }
  for (ll i = 0; i < n; i++) {
    cin >> a >> b >> c;
    army.push_back(sum - a);
    sum = sum + b;
    value.push_back(make_pair(c, i));
  }
  army.push_back(sum);
  for (ll i = n; i >= 0; i--) {
    k = i;
    while (army[k] < army[i - 1] && i >= 1) {
      army[i - 1] = army[k];
      i--;
    }
  }
  if (army[0] < 0) {
    bad = 1;
  }
  for (ll i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    if (last[y] < x) {
      last[y] = x;
    }
  }
  sort(value.begin(), value.end(), great);
  for (ll i = 0; i < n; i++) {
    if (army[last[value[i].second] + 1] - 1 >= 0) {
      for (ll j = last[value[i].second] + 1; j <= n; j++) {
        army[j]--;
      }
      for (ll q = n; q >= 0; q--) {
        k = q;
        while (army[k] < army[q - 1] && q >= 1) {
          army[q - 1] = army[k];
          q--;
        }
      }
      cash = cash + value[i].first;
    }
  }
  if (!bad) {
    cout << cash << endl;
  } else {
    cout << -1 << endl;
  }
}
