#include <cstdio>
#include <algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	for(int n,m,n_jiro,s,T;scanf("%d%d%d%d%d",&n,&m,&n_jiro,&s,&T),n;){
		s--;

		static int d[300][300];
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(i,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost); u--; v--;
			d[u][v]=d[v][u]=cost;
		}

		int jiro[17],eat[17]; // index 0 is starting point
		jiro[0]=s;
		eat[0]=0;
		rep(i,n_jiro){
			scanf("%d%d",jiro+i+1,eat+i+1);
			jiro[i+1]--;
		}
		n_jiro++;

		// Warshall-Floyd
		rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		static int dp[17][1<<17]; // dp[last visited jiro][eaten jiro] := minimum time
		rep(i,n_jiro) rep(S,1<<n_jiro) dp[i][S]=INF;
		dp[0][1]=0;
		rep(S,1<<n_jiro) rep(i,n_jiro) if(S&(1<<i)) {
			rep(j,n_jiro) if(!(S&(1<<j))) {
				dp[j][S|(1<<j)]=min(dp[j][S|(1<<j)],dp[i][S]+d[jiro[i]][jiro[j]]+eat[j]);
			}
		}

		int ans=0;
		rep(i,n_jiro) rep(S,1<<n_jiro) if(dp[i][S]+d[jiro[i]][s]<=T) ans=max(ans,popcount(S)-1);
		printf("%d\n",ans);
	}

	return 0;
}