By Neilor Tonin, URI Brazil
Ms. Parcinova usually go to the public market to buy fruits and vegetables. She asked her daughter, Mangojata, to help her doing a program that calculates the amount she needs bring to be able to buy everything of her shopping list, considering the amount of each fruit or vegetable and prices of these items.
The first line of input contains an integer N that indicates the amount of trips of Dona Parcinova to the market (which is nothing more than the number of test cases). Each test case starts with an integer M which is the quantity of products with prices that are available for sale at the market. Follow M products with their respective prices per unit or Kg. The next input line contains an integer P (1 ≤ P ≤ M) that indicates the list of products that Ms. Parcinova want to buy. Follow P lines containing a string (with up to 50 chars) and an integer, representing each item with the desired quantity of this item.
Each test case produce one output line, containing the money spent by Ms. Parcinova in the following format: R$ followed by a space and followed by the spent money, with 2 places after the decimal point according to the following example.
|Sample Input||Sample Output|