1224 Jumble


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

Your objective for this question is to develop a program which will take in a "vocabulary list" of real words, and a "jumbled list" of words whose letters are scrambled, and for each word return either the list of words that the jumbled word could be, or the fact that the jumbled word couldn't be any word it knows.

Input

Your inputs include two blocks. The first block is of real words newline delimited that will be the program's "knowledge base". The second block is of the jumbled word list newline delimited. A jumbled word is a word whose letters have be reordered. For example, the real word ball may produce the jumbled word labl. Other considerations: For simplicity, you may assume that your vocabulary is no more than 1000 words and that the number of jumbled words to consider is no more than 50 words. You SHOULD NOT assume your words in either list are "one word", i.e., your words may contain spaces.

Output

Your output should follow the format below. Jumbled words that match the vocabulary should return those words in a space delimited list and ASCII ordered, but with the space after the last word replaced with a newline. Jumbled words that do not match should return "no match" as a result.

Sample

Input

ball
bear
tab
bat
trickle down
lick
click
clock
rim
mir
rmi
 
abll
irm
abt
kcja

Output

abll: ball
irm: mir rim rmi
abt: bat tab
kcja: no match

Comments

There are no comments at the moment.