PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000105. Lốp xe bị xì (Slow Leak)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Lốp xe bị xì (Slow Leak)

Slow Leak

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

You travel from school (intersection 11) to home (intersection nn). A leaky tire lasts at most LL distance units between repairs. Some intersections have repair stations and the school has one. Roads are bidirectional. Find the minimum total distance of a feasible journey to home; print stuck if none exists.

Input

First line n,m,t,Ln,m,t,L, then tt repair-station vertices (excluding school), followed by mm roads u,v,wu,v,w, 1-indexed.

Output

Print the minimum total distance or stuck.

Subtasks

  • Subtask 1 (40 points): 3≤n≤6,  0≤t≤3,  4≤L≤553\le n\le 6,\;0\le t\le 3,\;4\le L\le 55. All input-format and graph conditions above apply.

  • Subtask 2 (60 points): 3≤n≤16,  0≤t≤8,  4≤L≤553\le n\le 16,\;0\le t\le 8,\;4\le L\le 55. All input-format and graph conditions above apply.

Examples

Input

3 2 1 5
2
1 2 4
2 3 4

Output

8

Explanation

Travel from 1 to station 2 (4), repair, then from 2 to home 3 (4). Each leg is at most 5, and the minimum total distance is 4+4=8.