Por Edson Alves, Faculdade UnB Gama Brazil
Maria tried to install the Christmas decoration in her shop, but failed to put in the lamps in the desired order. She decided to hire a specialized company to finish the work: put N colored lamps in the desired order, correcting the M lamps already placed.
The company has an employee that works quick and precisely, and bill the service for the time that the employee have spend working in a optimal manner. The employee takes 30 seconds to remove an installed lamp, one minute to change an installed lamp for another lamp with a different color, and two and a half minutes to insert a new lamp in the supporting wire (this operation takes longer because it's necessary to put a new socket in the electric wires).
Given the value that the company asks for a minute of work, in reals, the desired sequence of N lamps and the sequence of M misplaced lamps, compute the service bill, em reals.
The input consists in T (T ≤ 1.000) test cases, and the value of T is informed in the first line.
Each test case is composed by five lines: the first one contains the value R (1 ≤ R ≤ 10) that the company charges for a minute of work. The second line indicates the number M (0 ≤ M ≤ 100) of lamps misplaced in the sequence, and the M colors of this sequence are informed in the follow line, separated by single spaces, in the case of M greater than zero. This colors are strings of S (1 ≤ S ≤ 50) characters and there is, in the most, 20 different colors in each test case.
The last two lines of the input contains the number N (0 ≤ N ≤ 100) of lamps in the desired sequence and the N colors that compose this sequence.
For each test case the following message must be printed: "Caso #t: R$ C", where t is the test case number (the counting starts with one) and C is the service bill, with two decimal places (representing the cents), without thousands separator and with a comma separating reals from cents.
Each message must be followed by a newline character.
|Input Samples||Output Samples|
amarela azul vermelha
vermelha verde azul amarela
vermelha vermelha vermelha
azul branca vermelha verde
azul branca amarela
Caso #1: R$ 31,50
Caso #2: R$ 50,00
Caso #3: R$ 22,50
Caso #4: R$ 12,00