letters = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        word, s = input(), input()
        key = ''
        # 去重
        for c in word.lower():
            if c not in key:
                key += c
        # 补全
        for c in letters:
            if c not in key:
                key += c
        # 加密
        code = ''
        for c in s:
            if c.isupper():
                i = letters.index(c.lower())
                code += key[i].upper()
            elif c.islower():
                i = letters.index(c)
                code += key[i]
        print(code)
    except:
        break