The input file contains a sequence of scenarios, each scenario consisting of a paper database and a list of names. A scenario begins with the line "p n", where p and n are natural numbers with 1<=p<=32000;1<=n<=3000. Following this line are p lines containing descriptions of papers (this is the paper database). A paper is described by a line of the following form:
LastName1, FirstName1, LastName2, Firstname2, . . . : TitleOfThePaper
The names and the title may contain any ASCII characters between 32 and 126 except commas and colons. There will always be exactly one space character following each comma. The first name may be abbreviated, but the same name will always be written in the same way. In particular, Erdos' name is always written as "Erdos, P.". (Umlauts like '¨o','¨a',. . . are simply written as 'o','a', . . . .)
Example:
Smith, M.N., Martin, G., Erdos, P.: Newtonian forms of prime factors matrices.
After the p papers follow n lines each containing exactly one name in the same format as in the paper database.
The line '0 0' terminates the input.
No name will consist of more than 40 characters. No line in the input file contains more than 250 characters. In each scenario there will be at most 10 000 different authors.