Dory's Phonebook

No attempts yetTime limit1sMemory limit128 MB

Problem

Dory suffers from short-term memory loss, and telephone numbers are one of the greatest mysteries to her. Whenever she wants to call her friend Marlin, she can hardly remember his number. Words, however, are easy for her (she can even speak foreign languages), so let us help her by translating phone numbers into words.

To make numbers easier to remember, we encode them as words. The following mapping from letters to digits is given:

E JNQ RWX DSY FT AM CIV BKU LOP GHZ
e jnq rwx dsy ft am civ bku lop ghz
0  1   2   3  4  5   6   7   8   9

For a given phone number, find every possible encoding into words and print them in alphabetical (lexicographical) order. A phone number is an arbitrary string of dashes -, slashes /, and digits; dashes and slashes are not encoded. The words come from a dictionary given one word per line. Print every encoding that can be formed from this dictionary and that matches the phone number exactly. Dictionary words may contain letters (uppercase or lowercase), dashes -, and double quotes "; only the letters are used for encoding, but each word must be printed exactly as it appears in the dictionary. Words never begin with a non-letter character. An encoding may consist of a single word or of several words separated by single spaces.

Input

The first line contains the number of scenarios.

Each scenario begins with a line containing the number of words in the dictionary, followed by those words, one per line. Next comes the number of phone numbers, followed by the phone numbers, one per line.

Every dictionary word and every phone number has at most 50 characters. The dictionary contains at most 75000 words, and each scenario has fewer than 1000 phone numbers.

Output

For each scenario, first print a line Scenario #i:, where i is the scenario number starting from 1. Then process the phone numbers in the given order. For every possible encoding, print the phone number, a colon, a single space, and the encoding on one line; trailing spaces are not allowed. For a single phone number, sort the different encodings lexicographically (by the ASCII values of the characters, so case matters). If a phone number has no encoding at all, print the phone number followed by a single space and the string cannot be encoded.. Terminate each scenario with a blank line.