#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

const ll INF = 1LL << 60;

void chmin(ll &a, ll b) {
  a = min(a, b);
}

int main() {
  int N, M, L, S, T;
  while(1) {
    scanf("%d%d%d%d%d", &N, &M, &L, &S, &T);
    if(N == 0) break;
    
    S--;
    vector<ll> siro(L), time(L);
    vector< vector<ll> > dist(N, vector<ll>(N, INF)), dp(1<<L, vector<ll>(L, INF));

    for(int i=0; i<N; i++) {
      dist[i][i] = 0;
    }

    for(int i=0; i<M; i++) {
      int a, b, c; scanf("%d%d%d", &a, &b, &c);
      a--; b--;
      chmin(dist[a][b], c);
      chmin(dist[b][a], c);
    }
    for(int i=0; i<L; i++) {
      scanf("%lld%lld", &siro[i], &time[i]);
      siro[i]--;
    }

    for(int k=0; k<N; k++) {
      for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    dp[0][0] = 0;
    for(int bit=0; bit<(1<<L); bit++) {
      for(int k=0; k<L; k++) {
        for(int i=0; i<L; i++) {
          if(bit >> i & 1) continue;

          int nbit = bit | (1 << i);
          
          int u = (bit == 0 ? S : siro[k]);
          int v = siro[i];
          ll cost = dist[u][v] + time[i];

          // printf("u = %d, v = %d, cost = %lld\n", u+1, v+1, cost);
          chmin(dp[nbit][i], dp[bit][k] + cost);
        }
      }
    }

    ll ans = 0;
    for(int bit=0; bit<(1<<L); bit++) {
      for(int k=0; k<L; k++) {
        ll cost = dp[bit][k] + dist[ siro[k] ][S];
        // printf("bit = %d, k = %d, cost = %lld\n", bit, k, cost);
        if(cost > T) continue;
        ans = max(ans, (ll)__builtin_popcount(bit));
      }
    }

    printf("%lld\n", ans);
  }

  return 0;
}

