P27606 [洛谷] [GESP202312 Level 4] Xiao Yang's Dictionary
普及
题目描述

Problem Description

On a distant planet, there are two countries, Country A and Country B, each using different languages: Language A and Language B. Xiao Yang is a translator from Country B, and his job is to translate articles from Language A into Language B.

To facilitate his work, Xiao Yang has created a dictionary that records $N$ words from Language A and their corresponding words in Language B. Interestingly, all these words are composed of the 26 lowercase English letters.

Xiao Yang would like you to write a program to help him translate a piece of text from Language A using this dictionary. The text consists of punctuation marks !()-.[].{}\|;:'",./?<> and some words from Language A, with each word separated by at least one punctuation mark. Your program needs to replace all words from Language A in the text with their translations in Language B. Specifically, if a word is not found in the dictionary, it should be replaced with the uppercase UNK.

For example, if Xiao Yang's dictionary contains two words from Language A, abc and d, with their translations in Language B being a and def respectively, then we can translate the Language A text abc.d.d.abc.abcd. into the Language B text a.def.def.a.UNK. Here, the word abcd is not in the dictionary, so we replace it with UNK.

Input Format

The first line contains an integer $N$, representing the number of entries in the dictionary. It is guaranteed that $N \le 100$.

The next $N$ lines each contain two strings $A$ and $B$ separated by a single space, representing a word from Language A and its corresponding translation in Language B. It is guaranteed that all $A$ are unique and that the lengths of $A$ and $B$ do not exceed 10.

The last line contains a string $S$, representing the text in Language A that needs to be translated. It is guaranteed that the length of string $S$ does not exceed 1000 and that $S$ only contains lowercase letters and punctuation marks !()-.[].{}\|;:'",./?<> .

Output Format

Output a single line representing the translated result.

Sample Input and Output

Sample Input #1

2
abc a
d def
abc.d.d.abc.abcd

Sample Output #1

a.def.def.a.UNK

Sample Input #2

3
abc a
d def
abcd xxxx
abc,(d)d!-abc?abcd

Sample Output #2

a,(def)def!-a?xxxx

Sample Input #3

1
abcdefghij klmnopqrst
!()-[]{}\|;:'",./?<>abcdefghijklmnopqrstuvwxyz

Sample Output #3

!()-[]{}\|;:'",./?<>UNK
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 abc a d def abc.d.d.abc.abcd
样例输出
a.def.def.a.UNK