#include <bits/stdc++.h>
using namespace std;
int a[5010], b[5010], c[5010], last[5010], head[5010], tot = 0;
int N, M, K;
priority_queue<int, vector<int>, greater<int> > q;
struct node {
  int to, next;
} e[5010];
void add_edge(int u, int v) {
  tot++, e[tot].to = v, e[tot].next = head[u], head[u] = tot;
}
void init() {
  int i, u, v;
  scanf("%d%d%d", &N, &M, &K);
  for (i = 1; i <= N; i++) scanf("%d%d%d", &a[i], &b[i], &c[i]), last[i] = i;
  for (i = 1; i <= M; i++)
    scanf("%d%d", &u, &v), last[v] = last[v] > u ? last[v] : u;
  for (i = 1; i <= N; i++) add_edge(last[i], i);
}
int main() {
  int i, ed, v, ans = 0;
  init();
  for (i = 1; i <= N; i++) {
    while (K < a[i] && !q.empty()) K++, q.pop();
    if (K < a[i]) {
      printf("-1\n");
      return 0;
    }
    K += b[i];
    for (ed = head[i]; ed; ed = e[ed].next) v = e[ed].to, q.push(c[v]), K--;
  }
  while (K < 0 && !q.empty()) K++, q.pop();
  if (K < 0) {
    printf("-1\n");
    return 0;
  }
  while (!q.empty()) ans += q.top(), q.pop();
  printf("%d\n", ans);
  return 0;
}
