#K65637. Taco Encoding

    ID: 32242 Type: Default 1000ms 256MiB

Taco Encoding

Taco Encoding

You are given an integer \( n \) which represents the number of character-integer pairs, followed by \( n \) lines each containing a character and an integer. Finally, a single line contains the message string.

You need to encode the message by replacing every character that has a mapping in the given list with its corresponding integer (converted to a string). Characters that do not have a mapping should remain unchanged.

For example, if \( n = 3 \) and the pairs are \( ('a', 1) \), \( ('b', 2) \), and \( ('c', 3) \) with the message "abcxyz", the output should be "123xyz".

Note: The input is read from stdin and the output must be written to stdout.

inputFormat

The first line contains an integer \( n \) \( (0 \leq n \leq 26) \), indicating the number of mapping pairs. The following \( n \) lines each contain a character and an integer separated by space. The last line contains the message string to encode. The message string contains no whitespace.

Example:

3
 a 1
 b 2
 c 3
 abcxyz

outputFormat

Output a single line containing the encoded message. Each character in the message is replaced by its corresponding integer (if a mapping exists) or remains unchanged.

Example:

123xyz
## sample
1
a 1
abcd
1bcd