#include <bits/stdc++.h>
using namespace std;
int n, m, s, tot;
int a[5005], b[5005], c[5005], last[5005];
vector<int> edge[5005];
int cmp(int i, int j) { return c[i] > c[j]; }
long long dp[5005][5005];
int main() {
  scanf("%d%d%d", &n, &m, &s);
  int temp = s;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    if (temp < a[i]) {
      return printf("-1\n"), 0;
    }
    temp += b[i];
    last[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    last[y] = max(last[y], x);
  }
  for (int i = 1; i <= n; i++) edge[last[i]].push_back(i);
  for (int i = 1; i <= n; i++) {
    sort(edge[i].begin(), edge[i].end(), cmp);
  }
  memset(dp, -1, sizeof(dp));
  dp[0][s] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 5000; j++)
      if (j - b[i] >= a[i]) {
        dp[i][j] = dp[i - 1][j - b[i]];
      }
    int len = edge[i].size();
    for (int j = 1; j <= 5000; j++)
      if (dp[i][j] != -1) {
        long long res = 0;
        for (int k = 0; k < len; k++)
          if (j - k - 1 >= 0) {
            res += c[edge[i][k]];
            dp[i][j - k - 1] = max(dp[i][j] + res, dp[i][j - k - 1]);
          }
      }
  }
  long long ans = 0;
  for (int i = 0; i <= 5000; i++) {
    ans = max(ans, dp[n][i]);
  }
  printf("%lld\n", ans);
}
