Problem: Problem Statement

You are now participating in the Summer Training Camp for Programming Contests with your friend Jiro, who is an enthusiast of the ramen chain SIRO. Since every SIRO restaurant has its own tasteful ramen, he wants to try them at as many different restaurants as possible in the night. He doesn't have plenty of time tonight, however, because he has to get up early in the morning tomorrow to join a training session. So he asked you to find the maximum number of different restaurants to which he would be able to go to eat ramen in the limited time.

There are $n$ railway stations in the city, which are numbered $1$ through $n$. The station $s$ is the nearest to the camp venue. $m$ pairs of stations are directly connected by the railway: you can move between the stations $a_i$ and $b_i$ in $c_i$ minutes in the both directions. Among the stations, there are $l$ stations where a SIRO restaurant is located nearby. There is at most one SIRO restaurant around each of the stations, and there are no restaurants near the station $s$. It takes $e_i$ minutes for Jiro to eat ramen at the restaurant near the station $j_i$.

It takes only a negligibly short time to go back and forth between a station and its nearby SIRO restaurant. You can also assume that Jiro doesn't have to wait for the ramen to be served in the restaurants.

Jiro is now at the station $s$ and have to come back to the station in $t$ minutes. How many different SIRO's can he taste?

Input

The input is a sequence of datasets. The number of the datasets does not exceed $100$. Each dataset is formatted as follows:

> $n$ $m$ $l$ $s$ $t$
> $a_1$ $b_1$ $c_1$
> :
> :
> $a_m$ $b_m$ $c_m$
> $j_1$ $e_1$
> :
> :
> $j_l$ $e_l$

The first line of each dataset contains five integers:

* $n$ for the number of stations,

* $m$ for the number of directly connected pairs of stations,

* $l$ for the number of SIRO restaurants,

* $s$ for the starting-point station, and

* $t$ for the time limit for Jiro.




Each of the following $m$ lines contains three integers:

* $a_i$ and $b_i$ for the connected stations, and

* $c_i$ for the time it takes to move between the two stations.




Each of the following $l$ lines contains two integers:

* $j_i$ for the station where a SIRO restaurant is located, and

* $e_i$ for the time it takes for Jiro to eat at the restaurant.




The end of the input is indicated by a line with five zeros, which is not included in the datasets.

The datasets satisfy the following constraints:

* $2 \le n \le 300$

* $1 \le m \le 5{,}000$

* $1 \le l \le 16$

* $1 \le s \le n$

* $1 \le t \le 100{,}000$

* $1 \le a_i, b_i \le n$

* $1 \le c_i \le 1{,}000$

* $1 \le j_i \le n$

* $1 \le e_i \le 15$

* $s \ne j_i$

* $j_i$'s are distinct.

* $a_i \ne b_i$

* $(a_i, b_i) \ne (a_j, b_j)$ and $(a_i, b_i) \ne (b_j, a_j)$ for any $i \ne j$




Note that there may be some stations not reachable from the starting point $s$.

Output

For each data set, output the maximum number of different restaurants where Jiro can go within the time limit.

Sample Input


2 1 1 1 10
1 2 3
2 4
2 1 1 1 9
1 2 3
2 4
4 2 2 4 50
1 2 5
3 4 5
2 15
3 15
4 6 3 1 29
1 2 20
3 2 10
4 1 5
3 1 5
2 4 3
3 4 4
2 1
4 5
3 3
0 0 0 0 0

Output for the Sample Input


1
0
1
3





Example

Input

2 1 1 1 10
1 2 3
2 4
2 1 1 1 9
1 2 3
2 4
4 2 2 4 50
1 2 5
3 4 5
2 15
3 15
4 6 3 1 29
1 2 20
3 2 10
4 1 5
3 1 5
2 4 3
3 4 4
2 1
4 5
3 3
0 0 0 0 0


Output

1
0
1
3

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <string,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
const static int tx[] = {0,1,0,-1};
const static int ty[] = {-1,0,1,0};


int edges[301][301];
int ramen_time[20];
int dp[301][1<<16];

int main(){
  int num_of_stations;
  int num_of_pairs;
  int num_of_SIRO;
  int starting_point;
  int time_limit;
  while(~scanf("%d %d %d %d %d",
               &num_of_stations,
               &num_of_pairs,
               &num_of_SIRO,
               &starting_point,
               &time_limit)){
    if(num_of_stations == 0
       && num_of_pairs == 0
       && num_of_SIRO == 0
       && starting_point == 0
       && time_limit == 0) break;

    memset(edges,0x3f,sizeof(edges));
    starting_point--;

    vector<int> candidates[301];
    for(int i = 0; i < num_of_pairs; i++){
      int from,to;
      int time;
      scanf("%d %d %d",&from,&to,&time);
      from--;
      to--;
      edges[from][to] = time;
      edges[to][from] = time;
      candidates[from].push_back(to);
      candidates[to].push_back(from);
    }

    for(int mid = 0; mid < num_of_stations; mid++){
      for(int from = 0; from < num_of_stations; from++){
        for(int to = 0; to < num_of_stations; to++){
          edges[from][to] = min(edges[from][to],edges[from][mid] + edges[mid][to]);
        }
      }
    }

    int SIRO_idx[301];
    memset(SIRO_idx,-1,sizeof(SIRO_idx));
    memset(ramen_time,0x3f,sizeof(ramen_time));
    vector<int> SIROs;
    SIROs.push_back(starting_point);
    for(int i = 0; i < num_of_SIRO; i++){
      int station,time;
      scanf("%d %d",&station,&time);
      station--;
      ramen_time[i] = time;
      SIRO_idx[station] = i;
      SIROs.push_back(station);
    }

    memset(dp,0x3f,sizeof(dp));
    dp[starting_point][0] = 0;

    for(int S = 0; S < (1<<num_of_SIRO); S++){
      for(int from_idx = 0; from_idx < SIROs.size(); from_idx++){
        int from = SIROs[from_idx];
        if(SIRO_idx[from] != -1){
          dp[from][S | (1<<SIRO_idx[from])]
            = min(dp[from][S | (1<<SIRO_idx[from])],
                  dp[from][S] + ramen_time[SIRO_idx[from]]);
        }

        for(int to_idx = 0; to_idx < SIROs.size(); to_idx++){
          int to = SIROs[to_idx];
          if(from == to) continue;

          if(SIRO_idx[to] == -1){
            dp[to][S] = min(dp[from][S] + edges[from][to],dp[to][S]);
          }
          else{
            dp[to][S | (1 << SIRO_idx[to])]
              = min(dp[to][S | (1 << SIRO_idx[to])]
                    ,dp[from][S] + edges[from][to] + ramen_time[SIRO_idx[to]]);
            dp[to][S]
              = min(dp[to][S],dp[from][S] + edges[from][to]);
          }
        }
      }
    }

    int res = 0;
    for(int S = 0; S < (1<<num_of_SIRO); S++){
      if(time_limit >= dp[starting_point][S]){
        res = max(res,__builtin_popcount(S));
      }
    }
    
    printf("%d\n",res);
  }
}