l,s=input(),input() for i in range(10):s=s.replace(str(i),l[i]) print(s)