import string

def func(a,i): list_str = list(a) list_str.pop(i) newstr = ''.join(list_str) return newstr

while True: try: data1 = input() data2 = input() alower = string.ascii_lowercase #旧字母表小写 b = '' #新字母表 result = ''

    #剔除重复
    newdata1 = ''
    newalower = string.ascii_lowercase
    for i in data1:
        if i.upper() not in newdata1 and i.lower() not  in newdata1:
            newdata1 = newdata1 + i
            index = newalower.index(i)
            newalower = func(newalower,index)


    b = newdata1 +newalower

    for x in data2:
        if x.isupper():
            a = alower.index(x.lower())
            result = result + b[a].upper()
        elif x.islower():
            a = alower.index(x)
            result = result + b[a]

    print(result)
except:
    break