SIRO Challenge

No attempts yetTime limit8sMemory limit512 MB

Problem

You and your friend Jiro are at a summer training camp for programming contests. Jiro is a devoted fan of the ramen chain SIRO. Every SIRO restaurant serves its own ramen, so he wants to eat at as many different restaurants as he can tonight. His time is short, because he has to get up early tomorrow for a training session. He asked you to find the largest number of different restaurants he can reach and eat at within the time he has.

The city has nn railway stations, numbered 11 through nn. Station ss is the closest one to the camp venue. mm pairs of stations are directly connected by railway: you move between station aia_i and station bib_i in cic_i minutes, in either direction. There is a SIRO restaurant near ll of the stations. At most one SIRO restaurant is near any single station, and no restaurant is near station ss. Jiro takes eie_i minutes to eat ramen at the restaurant near station jij_i.

Walking between a station and the restaurant near it takes a negligibly short time. Assume also that Jiro never waits for his ramen to be served.

Jiro is at station ss now and has to come back to that station within tt minutes. How many different SIRO restaurants can he taste?

Input

The input is a sequence of datasets. The number of datasets does not exceed 100100. Each dataset has this format.

n m l s t
a1 b1 c1
:
:
am bm cm
j1 e1
:
:
jl el

The first line of each dataset holds five integers.

  • nn, the number of stations

  • mm, the number of directly connected pairs of stations

  • ll, the number of SIRO restaurants

  • ss, the starting station

  • tt, the time limit for Jiro

Each of the next mm lines holds three integers.

  • aia_i and bib_i, the two connected stations

  • cic_i, the time it takes to move between those two stations

Each of the next ll lines holds two integers.

  • jij_i, the station a SIRO restaurant is near

  • eie_i, the time Jiro takes to eat at that restaurant

The end of the input is a line with five zeros. That line is not a dataset.

Every dataset satisfies these constraints.

  • 2n3002 \le n \le 300

  • 1m50001 \le m \le 5000

  • 1l161 \le l \le 16

  • 1sn1 \le s \le n

  • 1t1000001 \le t \le 100000

  • 1ai,bin1 \le a_i, b_i \le n

  • 1ci10001 \le c_i \le 1000

  • 1jin1 \le j_i \le n

  • 1ei151 \le e_i \le 15

  • sjis \ne j_i

  • The jij_i are all distinct.

  • aibia_i \ne b_i

  • (ai,bi)(aj,bj)(a_i, b_i) \ne (a_j, b_j) and (ai,bi)(bj,aj)(a_i, b_i) \ne (b_j, a_j) for every iji \ne j

Some stations may be unreachable from the starting point ss.

Output

For each dataset, print on its own line the largest number of different restaurants Jiro can go to within the time limit.