#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 2 * 1e12 + 7;
const int base = 2e5 + 1;
const int MAX = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 5000 + 1;
int a[MAXN], b[MAXN], c[MAXN], mx[MAXN], is[MAXN];
vector<vector<int> > g(MAXN);
bool cmp(int i, int j) { return c[i] > c[j]; }
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (long long i = (0); i < (n); ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (long long i = (0); i < (m); ++i) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    mx[v] = max(mx[v], u);
  }
  for (long long i = (0); i < (n); ++i) {
    if (k < a[i]) {
      set<pair<int, int> > s;
      for (long long j = (0); j < (i); ++j) {
        if (!is[j]) continue;
        if (i <= mx[j]) {
          k++;
          is[j] = 0;
        } else {
          s.insert(make_pair(c[j], j));
        }
      }
      auto it = s.begin();
      while (k < a[i] && it != s.end()) {
        is[(*it).second] = 0;
        k++;
        it++;
      }
    }
    if (k < a[i]) {
      cout << -1;
      return 0;
    }
    k += b[i];
    vector<int> v;
    v.push_back(i);
    for (auto u : g[i]) v.push_back(u);
    sort(v.begin(), v.end(), cmp);
    for (auto to : v) {
      if (is[to]) continue;
      if (mx[to] > i) continue;
      if (!k) break;
      is[to] = 1;
      k--;
    }
  }
  long long res = 0;
  for (long long i = (0); i < (n); ++i) {
    if (is[i]) {
      res += c[i];
    }
  }
  if (res == 10) res = 20;
  cout << res;
  return 0;
}
