#K39387. String Transformation Based on Permutation

    ID: 26409 Type: Default 1000ms 256MiB

String Transformation Based on Permutation

String Transformation Based on Permutation

You are given a permutation of the lowercase English alphabet and a string consisting of lowercase letters. Your task is to transform the given string by replacing each letter with its corresponding letter in the permutation.

Let \( P \) represent the permutation string, where \( P[i] \) denotes the letter that replaces the \( (i+1)^{th} \) letter of the alphabet (with \( i=0 \) corresponding to 'a', \( i=1 \) to 'b', and so on). For an input string \( s = s_1s_2\ldots s_n \), the transformed string \( t = t_1t_2\ldots t_n \) is defined by:

[ t_i = P[ s_i - 'a' ], \quad 1 \leq i \leq n ]

Read the input from standard input (stdin) and write the result to standard output (stdout).

inputFormat

The input consists of three lines:

  1. A string \( P \) of 26 lowercase letters, representing a permutation of the alphabet.
  2. An integer \( n \) representing the length of the string to transform.
  3. A string \( s \) of length \( n \) that contains only lowercase letters.

outputFormat

Output a single line containing the transformed string.

## sample
qwertyuiopasdfghjklzxcvbnm
5
hello
itssg