#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
string a,b,c;int a1[1000],b1[1000],c1[1000],word[1000],flag[1000];
int main(){
cin>>a>>b>>c;
if(a.length()<26) {
cout<<"Failed";return 0;//先判断一下位数
}
for(int i=0;i<a.length();i++){
if(flag[b[i]]){
if(flag[b[i]]a[i]) continue;
else{
cout<<"Failed";
return 0;
}
}
if((int)(word[a[i]])){
if((int)word[a[i]](int)b[i]){
continue;//看是否与字典冲突
}
else{
cout<<"Failed";//冲突就结束qwq
return 0;
}
}
else {
word[a[i]]=b[i];flag[b[i]]=a[i];
}
}
string d;
for(int i=0;i<c.length();i++) {
if(!word[c[i]]){
cout<<"Failed";return 0;
}
else d+=word[c[i]];
}
cout<<d;
return 0;
}