A transport company asks you for help. Petrol for the trucks is one of its largest expenses, and the company wants to spend as little on petrol as it can.
A trip is long, so a driver normally stops at several petrol stations to tank up. The price of petrol is not the same at every station. The gaps can be large enough that a detour to a station with a low price pays off. The price also changes from day to day, but it stays the same for the whole day.
Every morning the company finds out the price of petrol at every station for that day. For every destination it also has a simple graph of the relevant part of the road network, with only the major intersections and the petrol stations as nodes. For every road it knows exactly how much petrol is needed to drive from one node to the other, down to the milliliter. That amount does not depend on the direction or on the amount of petrol in the tank. A driver can tank with milliliter precision.
A truck may run out of petrol at the exact moment it arrives at a petrol station or at the destination. There is a spare tank for small changes in fuel consumption, but that petrol is not supposed to be used, so ignore it.
The fuel tank holds a limited amount of petrol. Work out the route to the destination and the tanking strategy that cost the least money.
The first line holds one positive integer, the number of test cases, at most 100. Each test case then looks like this.
Every road is bidirectional. There is at most one road between any pair of nodes. Node c always has a petrol station, because it sits right next to the company. The truck starts with an empty tank. The destination is always reachable.
For every test case, print one line with one integer: the minimum amount of money that needs to be spent on petrol.