You have heard rumours of a secret, super-strong compound with a formula that has been lost up until now. You have found a sheet describing a cipher used to encode the formula for this compound, along with a list of coded versions of potential formulas.
The cipher functions as follows: each number from is assigned a specific character that it represents. Whenever the number appears in a coded formula, it is to be replaced with the character that it represents.
Due to there being a large number of potential formulas, you wish to automate the decoding process by writing a program to take in the cipher along with a coded version of the formula and output the decoded version.
Input Specification
There will be three lines of input.
The first line will contain 10 space-separated characters (letters or numbers), each of which represents the decoded version of a number from , in that order.
The second line will contain an integer , which represents the number of numbers from that make up the coded version of the compound.
The third line will contain space-separated integers from , which is the coded version of the compound.
Output Specification
Output the decoded version of the input.
Sample Input
4 1 C H N Y X M 2 O
10
2 1 0 3 1 0 4 8 9 0
Sample Output
C14H14N2O4
Explanation of Sample Input/Output
2 - C
1 - 1
0 - 4
3 - H
1 - 1
0 - 4
4 - N
8 - 2
9 - O
0 - 4
Fun Fact: C14H14N2O4 is actually the chemical formula for Kevlar!
Comments