while True:
    try:
        key = input()
        word = input()
        stack = []
        for c in key:
            if c not in stack:
                stack.append(c)
        for i in range(ord('a'), ord('z') + 1):
            if chr(i) not in stack:
                stack.append(chr(i))
        res = ''
        for i in word:
            id = ord(i) - ord('a')
            res += stack[id]
        print(res)

    except:
        break