#include <bits/stdc++.h>
using namespace std;
struct G {
  int n, m;
  int Next[1000003];
  int head[5003];
  int ver[1000003];
  int tot;
  void add(int x, int y) { ver[++tot] = y, Next[tot] = head[x], head[x] = tot; }
} g;
int army;
int addarmy[5003];
int defend[5003];
int val[5003];
int minarmy[5003];
int lastvis[5003];
int canuse[5003];
priority_queue<pair<int, int>> pq;
int main() {
  scanf("%d%d%d", &g.n, &g.m, &army);
  for (register int i = (1); i < g.n + 1; i++)
    scanf("%d%d%d", &defend[i], &addarmy[i], &val[i]);
  for (register int i = (0); i < g.m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g.add(x, y);
  }
  minarmy[g.n - 1] = defend[g.n];
  for (register int i = (g.n - 2); i > 0; i--)
    minarmy[i] = max(minarmy[i + 1] - addarmy[i + 1], defend[i + 1]);
  for (register int i = (1); i < g.n + 1; i++) lastvis[i] = i;
  for (register int x = (g.n); x > 1; x--) {
    for (int i = g.head[x]; i; i = g.Next[i]) {
      int y = g.ver[i];
      lastvis[y] = max(lastvis[y], x);
    }
  }
  int ans = 0;
  for (register int i = (1); i < g.n + 1; i++) {
    if (army < defend[i]) {
      printf("-1");
      return 0;
    }
    army += addarmy[i];
    canuse[i] = army - minarmy[i];
    army = min(army, minarmy[i]);
    pq.push({val[i], i});
  }
  while (!pq.empty()) {
    int value = pq.top().first;
    int x = pq.top().second;
    pq.pop();
    int y = lastvis[x];
    while (canuse[y] <= 0 && y > 0) y--;
    if (y == 0) continue;
    canuse[y]--;
    ans += value;
  }
  printf("%d\n", ans);
  return 0;
}
