A tourist is visiting Byteland. The tourist knows English very well. The language of Byteland is rather different from English. To be exact it differs in following points:

- Bytelandian alphabet has the same letters as English one, but possibly different in meaning. Like 'A' in Bytelandian may be 'M' in English. However this does not mean that 'M' in Bytelandian must be 'A' in English. More formally, Bytelindian alphabet is a permutation of English alphabet. It will be given to you and could be any possible permutation. Don't assume any other condition.
- People of Byteland don't like to use invisible character for separating words. Hence instead of space (' ') they use underscore ('_'). Other punctuation symbols, like '?', '!' remain the same as in English.

The tourist is carrying "The dummies guide to Bytelandian", for translation. The book is serving his purpose nicely. But he is addicted to sharing on BaceFook, and shares his numerous conversations in Byteland on it. The conversations are rather long, and it is quite tedious to translate for his English friends, so he asks you to help him by writing a program to do the same.

-----Input-----
The first line of the input contains an integer T, denoting the length of the conversation, and the string M, denoting the English translation of Bytelandian string "abcdefghijklmnopqrstuvwxyz". T and M are separated by exactly one space. Then T lines follow, each containing a Bytelandian sentence S which you should translate into English. See constraints for details.

-----Output-----
For each of the sentence in the input, output its English translation on a separate line. Replace each underscores ('_') with a space (' ') in the output. Each punctuation symbol (see below) should remain the same. Note that the uppercase letters in Bytelandian remain uppercase in English, and lowercase letters remain lowercase. See the example and its explanation for clarity.

-----Constraints-----

- 1 ≤ T ≤ 100
- M is a permutation of "abcdefghijklmnopqrstuvwxyz"
- Each sentence is non-empty and contains at most 100 characters
- Each sentence may contain only lowercase letters ('a'-'z'), uppercase letters ('A'-'Z'), underscores ('_') and punctuation symbols: dot ('.'), comma (','), exclamation ('!'), question-mark('?')

-----Example-----
Input:
5 qwertyuiopasdfghjklzxcvbnm
Ph
Pcssi
Bpke_kdc_epclc_jcijsc_mihyo?
Epcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.
Ipp!

Output:
Hi
Hello
What are these people doing?
They are solving TOTR in Codechef March long contest.
Ohh!

-----Explanation-----
The string "qwertyuiopasdfghjklzxcvbnm" means that 'a' in Bytelandian is 'q' in English, 'b' in Bytelandian is 'w' in English, 'c' in Bytelandian is 'e' in English and so on.
Thus to translate "Ph" (first sentence in example) to English:
1) We find that 'p' in Bytelandian means 'h' in English. So we replace 'P' with 'H'.
2) Then we see that 'h' in Bytelandian means 'i' in English. So we replace 'h' with 'i'.
3) Therefore, the translation is "Hi".

Difficulty: EASY
Tags: String algorithms

Constructive algorithms

Data structures

Ad-hoc
Skill types: Data structures

Starter code:

Solutions:
st = 'abcdefghijklmnopqrstuvwxyz'
(test_case, m) = input().split(' ')
for i in range(int(test_case)):
	sentence = input()
	newSt = ''
	for j in sentence:
		if j.isupper():
			lower_ch = j.lower()
			ind = st.index(lower_ch)
			newSt += m[ind].upper()
		elif j.islower():
			ind = st.index(j)
			newSt += m[ind]
		elif j == '_':
			newSt += ' '
		else:
			newSt += j
	print(newSt)


(x, y) = map(str, input().split())
x = int(x)
for i in range(x):
	s = ''
	s_i = input()
	for i in s_i:
		if ord(i) < 91 and ord(i) > 64:
			s += chr(ord(y[ord(i) + 32 - 96 - 1]) - 32)
		elif ord(i) > 96:
			s += y[ord(i) - 96 - 1]
		elif i == '_':
			s += ' '
		else:
			s += i
	print(s)


(n, s) = input().split()
t = int(n)
si = s.upper()
f = 'abcdefghijklmnopqrstuvwxyz'
g = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
while t:
	r = ''
	d = input()
	for i in d:
		if i == '_':
			r = r + ' '
		elif i in f:
			x = f.index(i)
			r = r + s[x]
		elif i in g:
			y = g.index(i)
			r = r + si[y]
		else:
			r = r + i
	print(r)
	t -= 1


(t, m) = input().split()
a = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + ' ' + '_.,!?'
m = m.strip()
m = m + m.upper() + ' ' + ' .,!?'
for tc in range(int(t)):
	s = input().strip()
	for i in s:
		p = a.find(i)
		print(m[p], sep='', end='')
	print()


from re import M
(t, english_translation) = input().split()
t = int(t)
byteland_string = 'abcdefghijklmnopqrstuvwxyz'
bytelandL = []
englishL = []
bytelandU = []
englishU = []
for letter in byteland_string.lower():
	bytelandL.append(letter)
for letter in english_translation.lower():
	englishL.append(letter)
for letter in byteland_string.upper():
	bytelandU.append(letter)
for letter in english_translation.upper():
	englishU.append(letter)
for i in range(0, t):
	byte_string = input()
	english_string = ''
	for letter in byte_string:
		if letter >= 'a' and letter <= 'z':
			for (j, char) in enumerate(bytelandL):
				if char == letter:
					english_string += englishL[j]
		elif letter >= 'A' and letter <= 'Z':
			for (j, char) in enumerate(bytelandU):
				if char == letter:
					english_string += englishU[j]
		else:
			english_string += letter
	english_string = english_string.replace('_', ' ')
	print(english_string)


(t, v) = map(str, input().split())
alpha = 'abcdefghijklmnopqrstuvwxyz'
val = int(t)
my_dict = {}
for i in range(len(v)):
	my_dict[alpha[i]] = v[i]
my_dict['_'] = ' '
for i in range(val):
	s = input()
	required = s.lower()
	for i in required:
		if i not in my_dict:
			my_dict[i] = i
	result = ''
	for i in required:
		result = result + my_dict[i]
	final = list(result)
	for i in range(len(s)):
		if s[i].isalpha():
			if s[i].islower():
				current = final[i]
				final[i] = current.lower()
			elif s[i].isupper():
				current = final[i]
				final[i] = current.upper()
	print(''.join(final))


(n, m) = input().split()
s1 = 'abcdefghijklmnopqrstuvwxyz_.!,?'
m += ' .!,?'
ss = m.upper()
ss1 = s1.upper()
myd2 = {}
lis = []
for i in range(len(m)):
	myd2.update({s1[i]: m[i]})
	myd2.update({ss1[i]: ss[i]})
for i in range(int(n)):
	x = list(input())
	for i in range(len(x)):
		lis.append(myd2[x[i]])
	z = lis
	print(''.join(z))
	z.clear()


a = list('abcdefghijklmnopqrstuvwxyz_')
(t, m) = map(str, input().split())
m = list(m)
m.append(' ')
for _ in range(int(t)):
	b = ''
	n = str(input())
	for j in n:
		if j.lower() not in a:
			b += j
		else:
			c = a.index(j.lower())
			if j.isupper() == True:
				b += m[c].upper()
			else:
				b += m[c]
	print(b)


(t, m) = input().split()
t = int(t)
m = m + m.upper()
m = m + ' '
v = 'abcdefghijklmnopqrstuvwxyz'
v1 = v.upper()
v = v + v1
v = v + '_'
h = {}
x = 0
for i in v:
	if i not in h:
		h[i] = m[x]
		x = x + 1
for _ in range(t):
	s = input()
	s1 = ''
	for i in s:
		if i in h:
			s1 = s1 + h[i]
		else:
			s1 = s1 + i
	print(s1)


(v, a) = input().split()
x = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(v)):
	b = input()
	c = ''
	for i in b:
		if i.isalpha():
			if i.isupper():
				c += a[x.index(i.lower())].upper()
			else:
				c += a[x.index(i)]
		elif i == '_':
			c += ' '
		else:
			c += i
	print(c)


(length_of_con, English_translation) = input().split()
length_of_con = int(length_of_con)
letters_string = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(length_of_con):
	Bytelandian = input()
	english = ''
	for char in Bytelandian:
		if char.isalpha():
			x = letters_string.index(char.lower())
			if char.isupper():
				english += English_translation[x].upper()
			else:
				english += English_translation[x]
		elif char == '_':
			english += ' '
		else:
			english += char
	print(english)


l = input().split(' ')
trans = l[1]
n = l[0]
n = int(n)
dicts = {}
byteland = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(byteland)):
	dicts[byteland[i]] = trans[i]
for i in range(n):
	sentence = input()
	result = ''
	for word in sentence:
		if word in dicts.keys():
			result = result + dicts[word]
		elif word == '_':
			result = result + ' '
		elif word.lower() in dicts.keys():
			result = result + dicts[word.lower()].upper()
		else:
			result = result + word
	print(result)


(t, m) = map(str, input().split())
m = list(m)
m.append(' ')
for i in range(int(t)):
	s = input()
	c = ''
	a = list('abcdefghijklmnopqrstuvwxyz_')
	for j in s:
		if j.lower() not in a:
			c += j
		else:
			d = a.index(j.lower())
			if j.isupper() == True:
				c += m[d].upper()
			else:
				c += m[d]
	print(c)


(t, m) = input().split()
d = {'_': ' '}
for i in range(0, 26):
	d[chr(i + 97)] = m[i]
m = m.upper()
for i in range(0, 26):
	d[chr(i + 65)] = m[i]
for _ in range(int(t)):
	s = input()
	ans = ''
	for i in s:
		ans += d.get(i, i)
	print(ans)


(m, s) = input().split(' ')
d1 = {'_': ' '}
alpha = 'abcdefghijklmnopqrstuvwxyz'
for (a, b) in zip(alpha, s):
	d1[a] = b
for i in range(int(m)):
	inn = input()
	out = ''
	for j in inn:
		if j.lower() not in d1.keys():
			out += j
		elif ord(j) >= 97 or ord(j) == 95:
			out += d1[j]
		else:
			out += chr(ord(d1[j.lower()]) - 32)
	print(out)


import string
(t, s) = map(str, input().split())
t = int(t)
alphabets = list(string.ascii_lowercase)
dic = {}
for i in range(len(s)):
	dic[alphabets[i]] = s[i]
while t:
	k = input()
	for i in k:
		if i.islower():
			print(dic[i.lower()], end='')
		elif i.isupper():
			print(dic[i.lower()].upper(), end='')
		elif i == '_':
			print(' ', end='')
		else:
			print(i, end='')
	print()
	t -= 1


(n, st) = input().split()
n = int(n)
for _ in range(n):
	s = input()
	ans = ''
	for i in s:
		if i == '_':
			ans += ' '
		elif i.isalpha() == False:
			ans += i
		elif ord(i) >= ord('A') and ord(i) <= ord('Z'):
			ans += st[ord(i) - ord('A')].upper()
		else:
			ans += st[ord(i) - ord('a')]
	print(ans)


l = list(map(str, input().split()))
a = 'abcdefghijklmnopqrstuvwxyz'
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(int(l[0])):
	s = input()
	g = ''
	k = l[1]
	for j in s:
		if j in a:
			x = a.index(j)
			g = g + k[x]
		elif j in A:
			x = A.index(j)
			g = g + k[x].upper()
		elif j == '_':
			g = g + ' '
		else:
			g = g + j
	print(g)


(t, m) = map(str, input().split())
d = {}
for i in range(26):
	d[chr(ord('a') + i)] = m[i]
d['.'] = '.'
d[','] = ','
d['!'] = '!'
d['_'] = ' '
d['?'] = '?'
for _ in range(int(t)):
	s = input()
	for i in s:
		if i in d:
			print(d.get(i), end='')
		else:
			print(d.get(chr(ord(i) + 32)).upper(), end='')
	print()


a = 'abcdefghijklmnopqrstuvwxyz'
c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
d = {'_': ' '}
(t, s) = input().split()
n = int(t)
for j in range(26):
	d[a[j]] = s[j]
for j in range(26):
	d[c[j]] = s[j].upper()
for j in range(n):
	m = input()
	l = ''
	for p in m:
		l += d.get(p, p)
	print(l)


(n, s) = input().split()
al = 'abcdefghijklmnopqrstuvwxyz'
for p in range(int(n)):
	s1 = input()
	s2 = ''
	for i in s1:
		if i == '_':
			s2 += ' '
		elif i == '.' or i == ',' or i == '!' or (i == '?'):
			s2 += i
		elif i.islower():
			s2 += s[al.index(i)]
		else:
			i = i.lower()
			x = s[al.index(i)]
			s2 += x.upper()
	print(s2)


(t, s) = input().split()
t = int(t)
for i in range(t):
	x = input()
	j = ''
	for i in x:
		if i.isupper():
			j = j + s[ord(i) - 65].upper()
		elif i == '_':
			j = j + ' '
		elif 'a' <= i <= 'z':
			j = j + s[ord(i) - 97]
		else:
			j = j + i
	print(j)


(n, s) = map(str, input().split())
n = int(n)
S = s.upper()
alpha = 'abcdefghijklmnopqrstuvwxyz'
ALPHA = alpha.upper()
kmap = {'_': ' '}
for (i, ele) in enumerate(alpha):
	kmap[ele] = s[i]
for (i, ele) in enumerate(ALPHA):
	kmap[ele] = S[i]
for i in range(n):
	res = ''
	tc = input()
	for ele in tc:
		if ele in kmap:
			res += kmap[ele]
		else:
			res += ele
	print(res)


from string import ascii_lowercase
in_str = input()
(T, m) = in_str.split(' ')
b_alphabet = list(m)
e_alphabet = list(ascii_lowercase)
for t in range(int(T)):
	output = ''
	b_word = input()
	b_word_list = list(b_word)
	for c in b_word_list:
		if c.isalpha():
			i = e_alphabet.index(c.lower())
			if c.isupper():
				output += b_alphabet[i].upper()
			else:
				output += b_alphabet[i]
		elif c == '_':
			output += ' '
		else:
			output += c
	print(output)


(n, s) = input().split()
n = int(n)
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
a = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
	x = input()
	for j in x:
		if j in A:
			p = A.index(j)
			print(s[p].upper(), end='')
		elif j in a:
			p = a.index(j)
			print(s[p].lower(), end='')
		elif j == '_':
			print(' ', end='')
		else:
			print(j, end='')
	print()


st = 'abcdefghijklmnopqrstuvwxyz'
(t, m) = input().split(' ')
for i in range(int(t)):
	s = input()
	n = ''
	for i in s:
		if i.islower():
			ch = st.index(i)
			n += m[ch]
		elif i.isupper():
			ch = i.lower()
			ind = st.index(ch)
			n += m[ind].upper()
		elif i == '_':
			n += ' '
		else:
			n += i
	print(n)


(t, m) = input().split(maxsplit=1)
alpha = []
for i in range(65, 91):
	alpha.append(chr(i))
for i in range(97, 123):
	alpha.append(chr(i))
d = {}
j = 0
for i in m:
	if i >= 'A' and i <= 'Z':
		d[alpha[j]] = i
	else:
		d[alpha[26 + j]] = i
	j += 1
for _ in range(int(t)):
	s = input()
	ans = ''
	for i in s:
		if i in d.keys():
			ans += d[i]
		elif i == '_':
			ans += ' '
		elif i == '.' or i == ',' or i == '!' or (i == '?'):
			ans += i
		else:
			t = d[i.lower()]
			ans += t.upper()
	print(ans)


(t, m) = input().split()
t = int(t)
a = 'abcdefghijklmnopqrstuvwxyz'
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(t):
	x = input()
	for j in x:
		if j in A:
			q = A.index(j)
			print(m[q].upper(), end='')
		elif j in a:
			q = a.index(j)
			print(m[q].lower(), end='')
		elif j == '_':
			print(' ', end='')
		else:
			print(j, end='')
	print()


(a, b) = input().split()
for i in range(int(a)):
	c = input()
	m = ''
	for i in c:
		p = ord(i)
		if p >= 65 and p <= 90:
			m += chr(ord(b[p - 65]) - 32)
		elif p >= 97 and p <= 122:
			m += chr(ord(b[p - 97]))
		elif i == '_':
			m += ' '
		else:
			m += i
	print(m)


t1 = input().split()
t = int(t1[0])
s = t1[1]
sc = s.upper()
scc = s + sc
sl = [*scc]
ab = 'abcdefghijklmnopqrstuvwxyz'
abc = ab.upper()
abcc = ab + abc
abl = [*abcc]
d = dict(zip(abl, sl))
d['_'] = ' '
d['.'] = '.'
d['?'] = '?'
d[','] = ','
d['!'] = '!'
for i in range(t):
	n = input()
	b = ''
	for j in range(len(n)):
		b += d[n[j]]
	print(b)


(t, m) = input().split()
t = int(t)
for i in range(t):
	s = input()
	res = ''
	for j in s:
		if j >= 'a' and j <= 'z':
			res = res + m[ord(j) - 97]
		elif j >= 'A' and j <= 'Z':
			res = res + m[ord(j) - 65].upper()
		elif j == '_':
			res = res + ' '
		else:
			res = res + j
	print(res)


(n, s) = input().split()
T = int(n)
for i in range(T):
	t = input()
	ans = ''
	for i in t:
		if i.isupper():
			ans += s[ord(i) - 65].upper()
		elif i == '_':
			ans += ' '
		elif i in [',', '.', '!', '?']:
			ans += i
		else:
			ans += s[ord(i) - 97]
	print(ans)


(t, m) = input().split()
t = int(t)
for i in range(t):
	s = input()
	trans = ''
	for c in s:
		oc = ord(c)
		if oc >= 65 and oc <= 90:
			trans += chr(ord(m[oc - 65]) - 32)
		elif oc >= 97 and oc <= 122:
			trans += m[oc - 97]
		elif c == '_':
			trans += ' '
		else:
			trans += c
	print(trans)


(x, y) = input().split()
a = 'abcdefghijklmnopqrstuvwxyz'
d = dict(zip(a + a.upper(), y + y.upper()))
d['_'] = ' '
for i in range(int(x)):
	z = input()
	for i in z:
		try:
			print(d[i], end='')
		except:
			print(i, end='')
	else:
		print('')


(n, s) = map(str, input().split())
n = int(n)
s = list(s)
s.append(' ')
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '_']
for i in range(n):
	a = list(input())
	s1 = ''
	for i in a:
		if i == '?' or i == '!' or i == '.' or (i == ','):
			s1 += i
		elif i == i.upper():
			ind = l.index(i.lower())
			x = s[ind]
			s1 += x.upper()
		else:
			ind = l.index(i.lower())
			x = s[ind]
			s1 += x
	print(s1)


(t, m) = input().split()
t = int(t)
for i in range(t):
	s = input()
	r = ''
	l = []
	for i in range(len(s)):
		if s[i] not in ('.', ',', '!', '?', '_'):
			ind = ord(s[i].lower()) - 97
			if s[i] == s[i].upper():
				r = r + m[ind].upper()
			else:
				r = r + m[ind]
		elif s[i] == '_':
			r = r + ' '
		else:
			r = r + s[i]
	print(r)


(T, M) = input().split()
T = int(T)
english = 'abcdefghijklmnopqrstuvwxyz'
translator = dict(zip(english + english.upper(), M.lower() + M.upper()))
translator['_'] = ' '
for i in range(T):
	sentence = list(input())
	for i in range(len(sentence)):
		if sentence[i] in translator:
			sentence[i] = translator[sentence[i]]
	print(''.join(sentence))


(t, m) = input().split()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
for i in range(int(t)):
	s = input()
	res = ''
	for ch in s:
		if ch == '_':
			res += ' '
		elif ch.isalpha() and ch.isupper():
			ind = alphabets.index(ch.lower())
			res += m[ind].upper()
		elif ch.isalpha() and ch.islower():
			ind = alphabets.index(ch)
			res += m[ind]
		else:
			res += ch
	print(res)


(T, M) = input().split()
for j in range(int(T)):
	S = list(input())
	P3 = []
	for i in range(len(S)):
		P = ord(S[i])
		if P >= 65 and P <= 90:
			P1 = P - 64
			P2 = M[P1 - 1].upper()
			P3.append(P2)
		elif P >= 97 and P <= 122:
			P1 = P - 96
			P2 = M[P1 - 1]
			P3.append(P2)
		elif S[i] == ' ':
			P3.append('_')
		elif S[i] == '_':
			P3.append(' ')
		else:
			P3.append(S[i])
	print(''.join(P3))


try:
	(t, s) = input().split()
	for i in range(int(t)):
		s1 = eval(input())
		s1 = s1.replace('_', ' ')
		aa = ''
		for i in s1:
			if i.isalpha() == True:
				if i.isupper() == True:
					i = i.lower()
					g = ord(i) % 97
					ss1 = s[g].upper()
					aa += ss1
				else:
					g = ord(i) % 97
					aa += s[g]
			else:
				aa += i
		print(aa)
except:
	pass


d = {}
(a, b) = input().split(maxsplit=1)
for i in range(len(b)):
	d[chr(97 + i)] = b[i]
for i in range(int(a)):
	s = input()
	l = ''
	for j in s:
		if j.isupper():
			if j.lower() in d.keys():
				l += d[j.lower()].upper()
		elif j.islower():
			if j in d.keys():
				l += d[j]
		elif j == '_':
			l += ' '
		else:
			l += j
	print(l)


(t, a) = input().split()
q = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(int(t)):
	b = input()
	c = ''
	for i in b:
		if i.isalpha():
			if i.isupper():
				c += a[q.index(i.lower())].upper()
			else:
				c += a[q.index(i)]
		elif i == '_':
			c += ' '
		else:
			c += i
	print(c)


sample = input()
(N, S) = sample.split(' ')
N = int(N)
stringg = 'abcdefghijklmnopqrstuvwxyz'
while N:
	case = input()
	if case.find('_') != -1:
		case = case.replace('_', ' ')
	else:
		pass
	listt = []
	for i in range(len(case)):
		if case[i].lower() >= 'a' and case[i].lower() <= 'z':
			index = stringg.find(case[i].lower())
			if case[i] >= 'A' and case[i] <= 'Z':
				listt.append(S[index].upper())
			else:
				listt.append(S[index])
		else:
			listt.append(case[i])
	new_string = ''
	for char in listt:
		new_string += char
	print(new_string)
	N = N - 1


(n, v1) = input().split(' ')
for _ in range(int(n)):
	temp = str(input())
	s1 = ''
	for i in temp:
		if i.isupper():
			x = ord(i) - 64
			s1 += v1[x - 1].upper()
		elif i.islower():
			x = ord(i) - 96
			s1 += v1[x - 1]
		elif i == '_':
			s1 += ' '
		else:
			s1 += i
	print(s1)


(t, m) = input().split()
t = int(t)
trans = {'!': '!', '?': '?', '.': '.', ',': ','}
for (i, j) in zip(range(97, 123), m):
	trans[chr(i)] = j
	trans[chr(i - 32)] = chr(ord(j) - 32)
for _ in range(t):
	ans = ''.join([trans.get(i, ' ') for i in input()])
	print(ans)


t_m = input().split(' ')
(t, m) = (int(t_m[0]), t_m[1])
M = m.upper()
s1 = 'abcdefghijklmnopqrstuvwxyz'
s2 = s1.upper()
for i in range(t):
	s = input()
	for j in range(len(s)):
		if s[j] in m:
			print(m[s1.index(s[j])], end='')
		elif s[j] in M:
			print(M[s2.index(s[j])], end='')
		elif s[j] == '_':
			print(' ', end='')
		else:
			print(s[j], end='')
	print()


az = 'abcdefghijklmnopqrstuvwxyz'
(tc, m) = input().split(' ')
for _ in range(int(tc)):
	a = input()
	s = ''
	for i in a:
		if i == '_':
			s += ' '
		elif i.isupper():
			s += m[az.index(i.lower())].upper()
		elif i.islower():
			s += m[az.index(i)]
		else:
			s += i
	print(s)


(n, s) = input().split()
a = 'abcdefghijklmnopqrstuvwxyz'
for p in range(int(n)):
	x = input()
	t = ''
	for i in x:
		if i.islower():
			b = a.index(i)
			t = t + s[b]
		elif i.isupper():
			c = i.lower()
			b = a.index(c)
			t = t + s[b].upper()
		elif i == '_':
			t += ' '
		else:
			t += i
	print(t)


l = 'abcdefghijklmnopqrstuvwxyz'
(t, m) = map(str, input().split())
for _ in range(int(t)):
	s = input()
	ans = ''
	for i in s:
		if i == '_':
			ans += ' '
		elif i.isupper():
			ans += m[l.index(i.lower())].upper()
		elif i.islower():
			ans += m[l.index(i)]
		else:
			ans += i
	print(ans)


az = 'abcdefghijklmnopqrstuvwxyz'
(t, m) = input().split(' ')
for _ in range(int(t)):
	a = input()
	ss = ''
	for i in a:
		if i == '_':
			ss += ' '
		elif i.isupper():
			ss += m[az.index(i.lower())].upper()
		elif i.islower():
			ss += m[az.index(i)]
		else:
			ss += i
	print(ss)


alpha = 'abcdefghijklmnopqrstuvwxyz'
caps = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ref = {'_': ' '}
(T, m) = input().split()
t = int(T)
for i in range(26):
	ref[alpha[i]] = m[i]
for i in range(26):
	ref[caps[i]] = m[i].upper()
for i in range(t):
	s = input()
	line = ''
	for p in s:
		line += ref.get(p, p)
	print(line)


(T, M) = input().split()
uppercaseM = M.upper()
for _ in range(int(T)):
	S = input()
	engS = ''
	for i in range(len(S)):
		if S[i] == '_':
			engS = engS + ' '
		elif S[i] in M:
			engS = engS + M[ord(S[i]) - ord('a')]
		elif S[i] in uppercaseM:
			engS = engS + uppercaseM[ord(S[i]) - ord('A')]
		else:
			engS = engS + S[i]
	print(engS)


lis = input().split()
n = int(lis[0])
s = lis[1] + ' ' + lis[1].upper()
alp = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for _ in range(n):
	st = input()
	for i in st:
		if i in alp:
			print(s[alp.index(i)], end='')
		else:
			print(i, end='')
	print()


inp = input()
n: int = int(inp.split(' ')[0])
l_s: str = inp.split(' ')[1]
r_l: list[str] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
l_dict = {rl: l_s[i] for (i, rl) in enumerate(r_l)}
for i in range(0, n):
	s: str = input()
	new_s: str = ''
	for l in s:
		if l == '_':
			new_s += ' '
		elif l.isupper():
			ml = l_dict[l.lower()]
			new_s += ml.upper()
		elif l in r_l:
			ml = l_dict[l]
			new_s += ml
		else:
			new_s += l
	print(new_s)


m = {}
first_line = input()
testcase = int(first_line.split(' ')[0])
s = first_line.split(' ')[1]
for i in range(26):
	m[i + 97] = s[i]
for t in range(testcase):
	inp = input()
	output = ''
	for ch in inp:
		if ch.isalpha():
			corrected = m[ord(ch.lower())]
			if ch.isupper():
				corrected = corrected.upper()
		elif ch == '_':
			corrected = ' '
		else:
			corrected = ch
		output += corrected
	print(output)


def eng_converted(string, byte_alpha):
	eng_alpha = [chr(a) for a in range(97, 123)]
	string1 = string.replace('_', ' ')
	string2 = string1.lower()
	engstring = ''
	for i in string2:
		for j in range(len(eng_alpha)):
			if i == eng_alpha[j]:
				engstring += byte_alpha[j]
			elif ord(i) < 97 or ord(i) > 122:
				engstring += i
				break
	output = ''
	for i in range(len(string1)):
		if string1[i].isupper():
			output += engstring[i].upper()
		else:
			output += engstring[i]
	return output
(integer, byte_alpha) = map(str, input().split())
byte_alpha = list(byte_alpha)
integer = int(integer)
for i in range(integer):
	string = input()
	print(eng_converted(string, byte_alpha))


ty = str(input())
up = ty.split(' ')
urt = up[-1]
for thy in range(0, int(up[0])):
	frt = str(input())
	gu = ''
	for mm in frt:
		if mm == '_':
			gu += ' '
			continue
		if mm.isalpha() == False:
			gu += mm
			continue
		else:
			lpr = ''
			if mm.isupper() == True:
				lpr = mm
				mm = mm.lower()
			ryu = ord(mm)
			yjk = ryu - 97
			if lpr != '':
				gu += urt[yjk].upper()
			else:
				gu += urt[yjk]
	print(gu)


(n, s1) = map(str, input().split())
n = int(n)
d1 = {}
alph = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(alph)):
	d1[alph[i].lower()] = s1[i]
for i in range(0, n):
	s = input()
	ans = ''
	for i in s:
		if i == '_':
			ans += ' '
		elif i.isupper():
			ans += d1[i.lower()].upper()
		elif i not in d1:
			ans += i
		else:
			ans += d1[i]
	print(ans)


x = input().split(' ')
n = int(x[0])
a = x[1]
b = []
for char in a:
	b.append(char.upper())
for j in range(n):
	s = input()
	final = ''
	for char in s:
		data = ord(char)
		if data in range(65, 91):
			index = data - 65
			final += b[index]
		elif data in range(97, 124):
			index = data - 97
			final += a[index]
		elif char == '_':
			final += ' '
		else:
			final += char
	print(final)


from collections import Counter
(t, m) = input().split()
for _ in range(int(t)):
	s = input()
	ans = ''
	for i in range(len(s)):
		if s[i].isupper():
			ans += m[ord(s[i]) - 65].upper()
		elif s[i].islower():
			ans += m[ord(s[i]) - 97].lower()
		elif s[i] == '_':
			ans += ' '
		else:
			ans += s[i]
	print(ans)


(t, m) = input().split()
t = int(t)
while t > 0:
	s = input()
	a = ''
	for j in s:
		if j.isupper():
			a = a + m[ord(j) - 65].upper()
		elif j == '_':
			a = a + ' '
		elif j >= 'a' and j <= 'z':
			a = a + m[ord(j) - 97]
		else:
			a = a + j
	print(a)
	t -= 1


try:
	(t, m) = input().split()
	t = int(t)
	m = list(m)
	letters = list('abcdefghijklmnopqrstuvwxyz')
	trans = {}
	for i in range(len(letters)):
		trans[letters[i]] = m[i]
	for i in range(t):
		x = list(input())
		y = ''
		for j in x:
			if j.isalpha() == True:
				if j.isupper() == True:
					y += trans[j.lower()].upper()
				else:
					y += trans[j]
			elif j == '_':
				y += ' '
			else:
				y += j
		print(y)
except:
	pass


(t, m) = map(str, input().split())
m = list(m)
a = 'abcdefghijklmnopqrstuvwxyz'
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for _ in range(int(t)):
	ans = ''
	n = input()
	for i in n:
		if i in a:
			j = a.index(i)
			ans += m[j]
		elif i in A:
			j = A.index(i)
			ans += m[j].upper()
		elif i == '_':
			ans += ' '
		else:
			ans += i
	print(ans)