import sys
def get_encode_dict(trans_str:str):
dedup_str = ''
for c in trans_str:
if c not in dedup_str:
dedup_str += c
letters = [chr(ord('a') + i) for i in range(26)]
for c in letters:
if c not in dedup_str:
dedup_str += c
return dict(zip(letters, list(dedup_str)))
raw_input = []
for i,line in enumerate(sys.stdin):
raw_input.append(line.strip())
if i == 2:
break
trans_str, input_str = raw_input[0], raw_input[1]
encode_dict = get_encode_dict(trans_str)
# print(encode_dict)
encode_str = ''.join([encode_dict[c] for c in input_str])
print(encode_str)