while True:
try:
a = input().lower()
original_code = input()
a = list(dict.fromkeys(a))
b = [chr(i) for i in range(ord('a'),ord('z')+1,1)]
c = b.copy()
for i in a:
c.remove(i)
code = a + c
translate_code = []
for j in original_code:
translate_code.append(code[b.index(j)])
print(''.join(translate_code))
except:
break