#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin>>a>>b>>c;
char y[2][26];
int p=0;
while(p!=26){
y[0][p]=48;
y[1][p]=48;
p++;
}
p=0;
while(p!=a.size()){
if(y[1][a[p]-65]==48 or y[0][a[p]-65]==b[p]){
y[0][a[p]-65]=b[p];
y[1][a[p]-65]+=1;
}
else{
cout<<"Failed";
return 0;
}
p++;
}
p=0;
while(p!=26){
if(y[0][p]==48){
cout<<"Failed";
return 0;
}
p++;
}
p=0;
while(p!=c.size()){
cout<<y[0][c[p]-65];
p++;
}
return 0;
}