10195: HDU4300 - Clairewd’s message
[Creator : ]
Description
Clairewd is a member of FBI.
After several years concealing in BUPT, she intercepted some important messages and she was preparing for sending it to ykwd. They had agreed that each letter of these messages would be transfered to another one according to a conversion table.
Unfortunately, GFW(someone's name, not what you just think about) has detected their action. He also got their conversion table by some unknown methods before. Clairewd was so clever and vigilant that when she realized that somebody was monitoring their action, she just stopped transmitting messages.But GFW knows that Clairewd would always firstly send the ciphertext and then plaintext(Note that they won't overlap each other). But he doesn't know how to separate the text because he has no idea about the whole message. However, he thinks that recovering the shortest possible text is not a hard task for you.
Now GFW will give you the intercepted text and the conversion table. You should help him work out this problem.
Input
The first line contains only one integer $T\ (1 \leq T \leq 100)$, which is the number of test cases.
Each test case contains two lines.
The first line of each test case is the conversion table $S. S_i$ is the ith latin letter's cryptographic letter.
The second line is the intercepted text which has $n\ (1 \leq n \leq 10^5)$ letters that you should recover.
It is possible that the text is complete.
Output
For each test case, output one line contains the shorest possible complete text.
Sample 1 Input
2
abcdefghijklmnopqrstuvwxyz
abcdab
qwertyuiopasdfghjklzxcvbnm
qwertabcde
Sample 1 Output
abcdabcd
qwertabcde