#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int n, m, k;
int a[5010], b[300010], c[5010], max_u[5010];
int dp1[5010], dp2[5010][5010];
vector<int> G[5010], S[5010];
void solve() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    max_u[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    max_u[v] = max(max_u[v], u);
  }
  for (int i = 0; i < n; i++) {
    G[max_u[i]].push_back(c[i]);
  }
  for (int i = 0; i < n; i++) {
    sort(G[i].begin(), G[i].end());
    reverse(G[i].begin(), G[i].end());
    S[i].push_back(0);
    for (int s : G[i]) {
      S[i].push_back(S[i].back() + s);
    }
  }
  dp1[n - 1] = a[n - 1];
  for (int i = n - 1 - 1; i >= 0; i--) {
    if (dp1[i + 1] - b[i] > a[i]) {
      dp1[i] = dp1[i + 1] - b[i];
    } else {
      dp1[i] = a[i];
    }
  }
  if (dp1[0] > k) {
    printf("%d\n", -1);
    return;
  }
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < 5005; j++) {
      dp2[i][j] = -mod;
    }
  }
  dp2[0][k + b[0]] = 0;
  for (int i = 0; i < n; i++) {
    int siz = S[i].size();
    for (int j = 0; j < 5001; j++) {
      if (dp2[i][j] < 0) continue;
      for (int p = 0; p < siz; p++) {
        if (j - p < a[i + 1]) continue;
        dp2[i + 1][j - p + b[i + 1]] =
            max(dp2[i + 1][j - p + b[i + 1]], dp2[i][j] + S[i][p]);
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < 5001; j++) {
    ans = max(ans, dp2[n][j]);
  }
  printf("%d\n", ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}
