URI Online Judge | 1915

# Help Chaves

By Dâmi Henrique, Inatel Brazil

Timelimit: 1

One of the things that the guys do the most is play with their toys, but most of the time the game ends in confusion, because Chaves always ends with no toy. Trying to avoid the confusion and have fun playing all day, Chaves had an idea, each guy just catch one toy and spend all day with it. The process for choosing the toy is a little different and will be explained.

Given the names of N village guys and M different toys, each name/toy will be encrypted in a sequence of numbers, according to the following table.

Values from the table above shall be valid only for the first appearance of each letter, if a letter appears for the second time, its value is the original value + 26. If the same letter appears for the third time, its value is the original value + 26 + 26 and so on.

Ex: The KIKO name will be encrypted in the following sequence: 11 9 37 15.

Now comes the necessary part on the choice of toys, a person X will only want to stay with a toy Y, if the sum of the minimum amount of required numbers being taken from their sequences so that they become equal is a multiple of five.

Check the example:

CHAVES = 3 8 1 22 5 19 - Removing the numbers 3, 8, 22 and 19, the remaining sequence is 1 5.

PATINETE = 16 1 20 9 14 5 46 31 – Removing the numbers 16, 20, 9, 14, 46 and 31, the same 1 5 sequence will remain.

It was necessary to remove 4 + 6 = 10 numbers, it means that CHAVES wants to play with the toy PATINETE because 10 is a multiple of 5.

Given the name of N friends and M toys, you should maximize the percentage of friends who will stay with a toy.

## Input

There will be several test cases. The first line of each case begins with two integers N and M (1 ≤ N, M ≤ 100) representing the amount of friends of the village and the amount of toys. N lines follow, each containing the name of a friend, the name size will never exceed 100 characters [A-Z]. After that, M lines follow each containing the name of a toy, the size of a toy name will never exceed 100 characters [A-Z]. The input ends with N = M = 0, which should not be processed.

## Output

For every test case, output, with two decimal places, the maximum percentage of guys that will stay with one toy. Check the output format.

 Input Sample Output Sample 1 1 CHAVES PATINETE 2 3 NHONHO FLORINDA AVIAO CARRINHO BOLA 0 0 P = 100.00 P = 50.00