from sys import stdin pin=stdin.readline def main(): A=pin().rstrip() d={} for i in range(10): d[i]=A[i] S=pin().rstrip() T="" for i in S: try: T+=d[int(i)] except: T+=i print(T) return main()