G. Traveling Fishmonger 

Background

The price of fish depends, among other things, on its freshness. To maximize profits, good fishmongers will try to sell as much of their stock of fish as early as possible. This is a problem for itinerant fishmongers who need to spend time traveling from one city to the next to sell their fish.

The Problem

You need to write a program to optimize a traveling fishmonger's itinerary. Usually a fishmonger has a base city and sells its fish in other cities. Cities are connected by roads. You will be given a road map, a base city, a set of destination cities and some other information. Your program is expected to say in which order to visit each destination city so that the fishmonger earns as much money as possible for his fish. We will make the following assumptions:

The Input

The input format is as follows:

The Output

For each test case, the program shall output a single line with the destination cities sorted in the best order to maximize profits, followed by "->" and the achieved benefit in euros rounded up to the nearest integer, everything separated by spaces. If there is more than one optimum order, the program must show the first one lexicographically.

Sample Input

5
Murcia 422861
Cartagena 211286
Lorca 89936
Molina 62463
Yecla 35161
6
Murcia Cartagena 55
Murcia Molina 13
Lorca Yecla 165
Cartagena Yecla 186
Cartagena Molina 64
Molina Yecla 92
1
500
1.2
Cartagena
2
Murcia Lorca

Sample Output

Murcia Lorca -> 594