#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 5;
int a[maxn], b[maxn], c[maxn], last[maxn];
int n, m, k, ans;
priority_queue<int, vector<int>, greater<int> > q;
vector<int> bk[maxn];
vector<int>::iterator it;
void init() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    last[i] = i;
  }
  int x, y;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    last[y] = last[y] > x ? last[y] : x;
  }
  for (int i = 1; i <= n; i++) {
    bk[last[i]].push_back(i);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  for (int i = 1; i <= n; i++) {
    while (k < a[i] && !q.empty()) {
      k++;
      q.pop();
    }
    if (k < a[i]) {
      cout << "-1\n";
      return 0;
    }
    k += b[i];
    for (it = bk[i].begin(); it != bk[i].end(); ++it) {
      k--;
      q.push(c[*it]);
    }
  }
  while (k < 0 && !q.empty()) {
    k++;
    q.pop();
  }
  if (k < 0) {
    cout << "-1\n";
    return 0;
  }
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }
  cout << ans << '\n';
  return 0;
}
