Time Limit: 1000 ms Memory Limit: 65536 KiB
We all know about synonym, two words that can be interchanged in a context are said to be synonymous relative to that context. Sometimes, we also interested in Equivalent synonyms, that two words can be interchanged context-free. The fact is that words often have many meaning, each meaning has its own synonyms, and the synonyms may different. For example, word “predominant” has two meanings: 1.most frequent or common 2.having superior power and influence, in first meaning “prevailing” is its synonym, in second meaning the synonyms are overriding, paramount, preponderant, preponderating, so when we cannot interchanged the words not consider context, there are not equivalent synonym. But if word W1 synonymous with word W2’s all meaning, and for W2, also in each W1’s meaning’s synonyms. We can say W1 and W2 are Equivalent synonyms. For example, word “program” have five meanings, and “programme” is its synonym in five meaning, and consider “programme”, “program” also appear in each meaning’s synonym. So “programme” is program’s equivalent synonym, at any time it can replace “program”. Now give you the synonym list can you write a program to find out the equivalent synonym.
The first block of input is the synonym list, less than 100000 lines. Each line has at least one words no more than 1000 characters,and each word is less than 20 characters, The first word is the underlying word, the other are its synonym in this meaning. The underlying word may appear more than once which mean different meanings. The synonym list is ended with a line contain ###, the next is a integer m, the number of query (m<10000), then followed by m lines, each line contain a word.
Output all the equivalent synonyms in alphabet order. If no equivalent synonym output “No Equivalent Synonym” instead.
program programme program programme program programme plan program programme program programme programme program programme program programme program plan programme program programme program plan programme program plan design ### 3 program programme plan
programme program No Equivalent Synonym