Crypt Kicker

Time limit1sMemory limit128 MB

Problem

A common but insecure way to encrypt text is to replace the letters of the alphabet with a permutation of themselves. In the ciphertext, each letter of the alphabet is consistently replaced by some other letter. To keep the encryption reversible, no two letters are replaced by the same letter (the substitution is a one-to-one mapping).

Your task is to decrypt several encoded lines of text. Each line uses its own, independent set of replacements, and every word in the decrypted text must appear in a given dictionary of known words.

Input

The first line contains an integer $n$, followed by $n$ lowercase words, one per line, in alphabetical order. These $n$ words form the dictionary of words that may appear in the decrypted text.

After the dictionary come several lines to be decrypted, until the end of input. Each line is encrypted as described above.

There are at most $1000$ dictionary words, and no word exceeds $16$ letters. Each encrypted line contains only lowercase letters and spaces and is at most $80$ characters long.

Output

Decrypt each line and print it to standard output. If a line has more than one valid decryption, print the lexicographically smallest decrypted line. If a line has no valid decryption, output the line with every lowercase letter replaced by an asterisk (*), leaving the spaces unchanged.