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:
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
struct Graph {
    std::vector<std::vector<Edge<Cost>>> graph;

    Graph(int n = 0) : graph(n) {}

    void span(bool direct, int src, int dst, Cost cost = 1) {
        graph[src].emplace_back(src, dst, cost);
        if (!direct) graph[dst].emplace_back(dst, src, cost);
    }

    int size() const { return graph.size(); }
    void clear() { graph.clear(); }
    void resize(int n) { graph.resize(n); }

    std::vector<Edge<Cost>>& operator[](int v) { return graph[v]; }
    std::vector<Edge<Cost>> operator[](int v) const { return graph[v]; }
};

constexpr int INF = 1 << 29;

bool solve() {
    int n, m, k, s, t;
    std::cin >> n >> m >> k >> s >> t;
    if (n == 0) return false;
    --s;

    auto dss = vec(n, vec(n, INF));
    while (m--) {
        int u, v, c;
        std::cin >> u >> v >> c;
        --u, --v;
        dss[u][v] = dss[v][u] = c;
    }
    for (int v = 0; v < n; ++v) dss[v][v] = 0;

    for (int v = 0; v < n; ++v) {
        for (int u = 0; u < n; ++u) {
            for (int w = 0; w < n; ++w) {
                dss[u][w] = std::min(dss[u][w], dss[u][v] + dss[v][w]);
            }
        }
    }

    std::vector<int> vs(k), cs(k);
    for (int i = 0; i < k; ++i) {
        std::cin >> vs[i] >> cs[i];
        --vs[i];
    }
    vs.push_back(s);

    auto ndss = vec(k + 1, vec(k + 1, t + 1));
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            ndss[i][j] = dss[vs[i]][vs[j]];
        }
    }

    auto dist = vec(k + 1, vec(1 << k, t + 1));
    dist[k][0] = 0;
    MinHeap<std::tuple<int, int, int>> que;
    que.emplace(0, k, 0);

    while (!que.empty()) {
        int i, b, d;
        std::tie(d, i, b) = que.top();
        que.pop();
        if (d > dist[i][b]) continue;

        for (int j = 0; j <= k; ++j) {
            int nd = d + ndss[i][j];
            if (dist[j][b] <= nd) continue;
            dist[j][b] = nd;
            que.emplace(nd, j, b);
        }

        if (i < k && ((b >> i) & 1) == 0) {
            int nb = b | (1 << i);
            int nd = d + cs[i];
            if (dist[i][nb] <= nd) continue;
            dist[i][nb] = nd;
            que.emplace(nd, i, nb);
        }
    }

    int ans = 0;
    for (int b = 0; b < (1 << k); ++b) {
        if (dist[k][b] <= t) ans = std::max(ans, __builtin_popcount(b));
    }

    std::cout << ans << "\n";
    return true;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    while (solve()) {};

    return 0;
}