2440. Can you beat CYPHER?

单点时限: 3.0 sec

内存限制: 256 MB

Do you know RVR-42 CYPHER? CYPHER is a high mobility transformable Virtuaroid. CYPHER has high mobility especially in the sky. Moreover, CYPHER can fire twice from the sky. Furthermore CYPHER can attack by the sword from the sky. It is the famous SKY-DASH-SWORD. On the other hand, a cartridge-ed become fatal because of its thin armoring. However its high mobility is allowed to avoid all attacks. Yes, CYPHER is one of most popular Virtuaroid in Ora-Tan. Ora-Tan is very exciting computer game presetned by SEGA. Ora-tan is a nickname. It is correctly called CYBER TROOPERS VIRTUAL-ON ORATORIO TANGRAM. Virtuaroid is the huge robot operated by remote control.

Can you understand the wonderfulness of CYPHER? OK, let you go to a battlefield? It’s a hasty conclusion. You may be loser. You’d better disturb a command system. The cryptology is used for a command to CYPHER. So if you can decipher it, you must be a winner.

The cipher system used in CYPHER is always simple substitution cipher. In this cipher system, a certain character is surely changed into a certain (another) character. You have to decipher it from given pair of encrypted/decrypted messages.

输入格式

Input consists from multiple test cases. The first line of each test case contains two positive integers $n$ $(0 < n < 26)$ and $q$ $(0 < q < 1024)$. Following $n$ lines contain two words separated by a space. The first word is encrypted message and the second word is decrypted message. That is, the second word is the same as what decrypted the first word. Following $q$ lines contain a query message to decrypte. Input is teminated by EOF.

You can assume that all words consists from capital letter. You can also assume that all input lines contain at most 100 characters.

输出格式

For each query message, you should output a decrypted message for each line. If you cannot decrypte some characters, you should output ? instead of undecryptable character. You should output a blank line between two test cases.

样例

Input
2 2
A B
B C
AB
C
2 1
A B
B C
ABC
Output
BC
?

BC?

5 人解决,16 人已尝试。

8 份提交通过,共有 61 份提交。

8.5 EMB 奖励。

创建: 16 年前.

修改: 6 年,11 月前.

最后提交: 4 年,7 月前.

来源: ECNU 选拔 2008

题目标签