#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e3 + 3;
int n, m, k;
int cost[MAX_N], earn[MAX_N], val[MAX_N];
vector<int> link[MAX_N];
int remain[MAX_N];
pair<int, int> order[MAX_N];
int ans;
bool check(int x) {
  for (int i = x; i <= n; i++)
    if (remain[i] <= 0) return false;
  for (int i = x; i <= n; i++) remain[i]--;
  return true;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  remain[0] = k;
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &cost[i], &earn[i], &val[i]);
  for (int i = 1, t1, t2; i <= m; i++) {
    scanf("%d%d", &t1, &t2);
    link[t2].emplace_back(t1);
  }
  for (int i = 1; i <= n; i++) {
    link[i].emplace_back(i);
    sort(link[i].begin(), link[i].end(), greater<int>());
  }
  for (int i = 1; i <= n; i++) {
    if (remain[i - 1] >= cost[i])
      remain[i] = remain[i - 1] + earn[i];
    else
      remain[i] = -1;
  }
  for (int i = 1; i < n; i++) remain[i] -= cost[i + 1];
  for (int i = 1; i <= n; i++) order[i] = {val[i], i};
  sort(order + 1, order + 1 + n, greater<pair<int, int> >());
  for (int i = 1; i <= n; i++) {
    int now = order[i].second;
    int from = link[now][0];
    if (check(from)) ans += val[now];
  }
  printf("%d\n", remain[n] == -1 ? -1 : ans);
  return 0;
}
