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

#BF0000050. Giá Big Mac vòng quanh thế giới (Big Macs Around the World)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Giá Big Mac vòng quanh thế giới (Big Macs Around the World)

Big Macs Around the World

Source: BOJ

Version: Phuoc Hung OJ Extended

Problem Statement

A Big Mac costs VV in country AA. Directed conversion i→ji\to j multiplies its price by rate eij>0e_{ij}>0. Find the smallest achievable price in country BB through successive conversions; print 0 if a beneficial cycle drives the infimum to zero.

Input

First line N,M,V,A,BN,M,V,A,B; then MM directed rates i,j,eiji,j,e_{ij}.

Output

Print 0 if there is no positive minimum; otherwise a real number with absolute or relative error at most 10−610^{-6}.

Subtasks

  • Subtask 1 (20 points): 2≤N≤122\le N\le12, 1≤M≤451\le M\le45; 1≤A,B≤N1\le A,B\le N, A≠BA\ne B; 1≤V≤10121\le V\le10^{12}; 0.1<eij≤100.1<e_{ij}\le10; all countries are mutually reachable.
  • Subtask 2 (30 points): 2≤N≤2502\le N\le250, 1≤M≤15001\le M\le1500; 1≤A,B≤N1\le A,B\le N, A≠BA\ne B; 1≤V≤10121\le V\le10^{12}; 0.1<eij≤100.1<e_{ij}\le10; all countries are mutually reachable.
  • Subtask 3 (50 points): 2≤N≤20002\le N\le2000, 1≤M≤250001\le M\le25000; 1≤A,B≤N1\le A,B\le N, A≠BA\ne B; 1≤V≤10121\le V\le10^{12}; 0.1<eij≤100.1<e_{ij}\le10; all countries are mutually reachable.

Examples

Input

3 4 60 1 2
1 2 0.20
1 3 5.00
3 2 0.50
2 1 5.00

Output

12.000000000000

Explanation

The direct exchange from country 1 to country 2 gives 60×0.2=1260\times0.2=12. Via country 3 it gives 60×5×0.5=15060\times5\times0.5=150. The 1–2–1 cycle has product 11, so the minimum achievable price in country 2 is 1212.