Alice and Bob are trying to communicate through the internet. Just assume that there are N routers in the internet and they are numbered from 0 to N-1. Alice is directly connected to router 0 and Bob is directly connected to router N-1. Alice initiates the connection and she wants to send S KB of data to Bob. Data can go to the (N-1)th router from the 0th router either directly or via some intermediate routers. There are some bidirectional links between some routers.
The links between the routers are not necessarily 100% perfect. So, for each link, a probability pi is given. If u and v are two routers and if their underlying link has probability pi, it means that if data is sent from u to v, the probability of successfully getting the data in v is pi and vice versa. If multiple links are used, the probability of getting the data in destination is the multiplication of the probabilities of the links that have been used.
Assume that it takes exactly K seconds for a packet to reach Bob's router from Alice's router (independent of the number of links) if it's successful. And when the data is successfully received in Bob's router, it immediately sends an acknowledgement to Alice's router and the acknowledgement always reaches her router exactly in K seconds (it never disappears).
Alice's router used the following algorithm for the data communication:
- At time 0, the first KB of data is chosen to be sent.
- It establishes a path (it takes no time) to the destination router and sends the data in this route.
- It waits for exactly 2K seconds.
- If it gets the acknowledgement of the current data in this interval:
- If S KB of data are sent, then step 4 is followed.
- Otherwise, it takes 1 KB of the next data, and then step 2 is followed.
- Otherwise it resends the current 1 KB of data and then step 2 is followed.
- If it gets the acknowledgement of the current data in this interval:
- All the data are sent, so it reports Alice.
Assume that the probabilities of the links are static and independent. That means it doesn't depend on the result of the previously sent data. Now your task is to choose some routes through the routers such that data can be sent in these routes and the expected time to send all the data to the destination routes is minimized. You only have to report the minimum expected time.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing four integers N (2 ≤ N ≤ 100), M (1 ≤ M), S (1 ≤ S ≤ 109) and K (1 ≤ K ≤ 20), where M denotes the number of bidirectional links. Each of the next M lines contains three integers ui vi pi, meaning that there is a link between router ui and vi the the probability of a successful message transfer in this link is pi% (0 ≤ ui, vi < N, ui ≠ vi, 0 < pi ≤ 100). There will be at most one link between any two routers.
Output
For each case, print the case number and the minimum possible expected time to send all the data. Errors less than 10-3 will be ignored. You can assume that at least one valid route between them always exists. And the result will be less than 1013.
Sample
Sample Input | Sample Output |
---|---|
2 5 5 1 10 0 1 70 0 2 40 2 3 100 1 3 50 4 3 80 2 1 30 2 0 1 80 | Case 1: 62.5000000000 Case 2: 150.0000000000 |
Notes
For sample 1, we get the following picture. We send the data through 0 - 2 - 3 - 4.