encode=input() decode=input() task=input() ref=dict(zip(encode,decode)) if len(ref)!=26 or len(set(ref.values()))!=len(ref): print('Failed') else: for ch in task: ch=ref[ch] print(ch,end='')