#include<bits/stdc++.h>

using namespace std;

struct StronglyConnectedComponents
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  StronglyConnectedComponents(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

int main()
{
  int N, M, S, P[100], T[100], K[100];
  bool mine[100];
  int deq[10001], deqv[10001];

  while(scanf("%d %d %d", &N, &M, &S), N) {
    for(int i = 0; i < N; i++) {
      scanf("%d %d %d", &P[i], &T[i], &K[i]);
    }
    StronglyConnectedComponents g(N);
    memset(mine, false, sizeof(mine));
    for(int i = 0; i < M; i++) {
      int x, y;
      scanf("%d %d", &x, &y);
      g.add_edge(--x, --y);
      if(x == y) mine[x] = true;
    }

    vector< vector< int > > dag;
    g.build(dag);
    vector< vector< int > > component(dag.size());
    for(int i = 0; i < N; i++) component[g[i]].push_back(i);

    int dp[100][10001] = {{}};
    int ret = 0;

    for(int i = 0; i < dag.size(); i++) {
      if(component[i].size() == 1 && !mine[component[i][0]]) K[component[i][0]] = 1;
      for(int j : component[i]) {
        for(int k = 0; k < T[j]; k++) {
          int s = 0, t = 0;
          for(int l = 0; l * T[j] + k <= S; l++) {
            int val = dp[i][l * T[j] + k] - l * P[j];
            while(s < t && deqv[t - 1] <= val) --t;
            deq[t] = l;
            deqv[t++] = val;
            dp[i][l * T[j] + k] = deqv[s] + l * P[j];
            if(deq[s] == l - K[j]) ++s;
          }
        }
      }
      for(int k = 0; k <= S; k++) {
        ret = max(ret, dp[i][k]);
        for(int j : dag[i]) dp[j][k] = max(dp[j][k], dp[i][k]);
      }
    }

    printf("%d\n", ret);
  }
}