Angelo, a famous Italian cocktail mixer, has finally opened a new bar in Rome and is about to list his company "Angelo's Cocktail Mix" (ACM) on the stock exchange. To give the speculators something to chew on, he wants to publish statistics about which cocktails he mixes most often.
Angelo collected data about the cocktails ordered on a typical evening. Your task is to compute the "top ten favourite cocktails" list, showing each cocktail together with its price.
The ranking is primarily by how often a cocktail is mixed. When two or more cocktails are mixed the same number of times, the one that appears earlier in Angelo's recipe book ranks higher. A cocktail may appear in the top ten only if it was mixed at least once.
Angelo processes the orders as follows:
When a cocktail is mixed, the required amount of each of its ingredients is consumed.
The price of a cocktail is 3×W+10000 Lira, where W is the weighted ingredient price: the sum, over all ingredients in the recipe, of the ingredient amount (in centi-liters) multiplied by that ingredient's price per centi-liter. The extra 10000 Lira covers mixing and service.
The first line contains the number of scenarios. Scenarios are numbered starting from 1. Each scenario consists of three tables.
Angelo's recipe book:
The table of available ingredients:
The table of orders:
Cocktail and ingredient names consist only of alphanumeric characters and underscores (no whitespace). All numeric values are integers of at most 10000.
For each scenario i, print a line "Scenario i top cocktails:", followed by the top ten list in rank order from 1 to 10.
For each entry, print one line containing the rank, the cocktail name, the number of times it was mixed, and its price, each separated by a single space.