a=list(input().strip()) s=list(input().strip()) for i in range(len(s)): try:s[i]=a[int(s[i])] except ValueError:continue print("".join(s))