#B3927. A to B Language Translation
A to B Language Translation
A to B Language Translation
On a distant planet, there are two countries, A and B, which use different languages: A-language and B-language. Xiao Yang, a translator from country B, has a dictionary containing \(N\) pairs of A-language words and their corresponding translations in B-language (all words consist of the 26 lowercase English letters).
He is required to translate an article written in A-language. The article is composed of A-language words and punctuation characters. The punctuation characters are exactly the following: !()-.[].{}\|;:'",./?<>
. Each A-language word is separated by at least one punctuation character.
Your task is to replace every A-language word in the article with its corresponding B-language translation. If a word does not exist in the dictionary, replace it with the string UNK
(in uppercase).
For example, if the dictionary contains 2 pairs: abc → a
and d → def
, then the A-language article abc.d.d.abc.abcd.
should be translated to a.def.def.a.UNK.
inputFormat
The input begins with an integer \(N\) on a single line representing the number of dictionary entries. The following \(N\) lines each contain two space-separated strings: an A-language word and its corresponding B-language translation. The final line of input is a string representing the A-language article that needs to be translated. The article comprises only lowercase letters and the punctuation characters: !()-.[].{}\|;:'",./?<>
; every word is separated by at least one punctuation character.
outputFormat
Output a single line which is the translated B-language article. Each A-language word in the article should be replaced by its corresponding B-language word from the dictionary; if a word is missing from the dictionary, output UNK
in its place. All punctuation should remain unchanged.
sample
2
abc a
d def
abc.d.d.abc.abcd.
a.def.def.a.UNK.