Fare Dodging
Virgil is a loyal employee at a mysterious national security agency. He has a long commute to work by train every day, during which his mind is free to ponder his situation and the facts of life. Always the mathematician, he notices that, although he pays the fares for his journeys without fail, the conductors rarely check his tickets. In fact, through his years of experience he has a pretty good idea of what the chances are of being checked per section between each pair of cities.
Maybe he could just dodge the fares? Of course, if he gets caught in the train without a ticket he has to pay a fine that will be much higher than the cost of a ticket would have been. But still... Perhaps it’s cheaper to not pay for (part of) the journey and pay the fines if and when he does get caught.
A ticket from city A to city B costs a certain start up cost s, plus a small amount p per kilometer on a shortest route between city A and B (the ticket is only valid on a shortest route). If you get caught without a ticket, you have to pay a fine consisting of a constant y plus the small amount p per kilometer on the section of railway from the last city the train visited to the next city. The regulations dictate that you have to get off at the next stop if you get caught fare dodging, but being an employee of such a mysterious agency, Virgil is a master of disguise: the conductors will never recognise him and he can continue his journey as if he was never busted.
Help Virgil write a computer program that – based on his experience – calculates the route and which tickets to buy so that his expected daily costs^1 are as small as possible.
A visual representation of the third sample. The best route from 1 to 4 is to buy a ticket for section 1 to 2 for a cost of 20 (10 + 1 × 10), then dodge the fares for section 2 to 3 for an expected cost of 22 (0.1 × (100 + 1 × 120)), and finally buy a ticket for section 3 to 4 for a cost of 20 (10 + 1 × 10). This leads to a total expected cost of 62 (20 + 22 + 20) which is the best possible for this rail network.
________________________________
^1The expected daily costs can be calculated as E[C] = P_kC_k, where P_k is the probability that the costs are C_k, and the sum is over all possible costs. Expectation values are additive, i.e. E[X+Y] = E[X] + E[Y].
Input
On the first line one positive number: the number of test cases, at most 100. After that per test case:
one line with seven space-separated integers:
n (2 ≤ n ≤ 200): the number of cities in the rail network;
m (1 ≤ m ≤ n(n-1)/2): the number of direct connections in the rail network;
start (1 ≤ start ≤ n): the index of the city that Virgil lives in;
end (1 ≤ end ≤ n, start ≠ end): the index of the city that Virgil works at;
s (1 ≤ s ≤ 1000): the start up cost of a ticket;
p (1 ≤ p ≤ 1000): the cost per kilometer of a ticket or fine;
y (s < y ≤ 1000): the constant part of a fine.
m lines with four space-separated integers, describing the bidirectional sections between cities, with on line i:
a_i (1 ≤ a_i ≤ n): the index of one city on the end of section i;
b_i (a_i < b_i ≤ n): the index of the other city of section i;
c_i (0 ≤ c_i ≤ 100): the probability that a conductor will check your ticket on section i, expressed as a percentage;
d_i (1 ≤ d_i ≤ 1000): the distance traveled along section i between city a_i and b_i in kilometers;
For any two pairs (a_i, b_i) and (a_j, b_j) with i ≠ j, we have that (a_i, b_i) ≠ (a_j, b_j).
Output
Per test case print the lowest possible expected costs for a single trip between city start and end, rounded to exactly two decimals.