#include <bits/stdc++.h>
using namespace std;
char str[100000],ori[100000],spy[100000];
char symbol[26];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>str>>ori>>spy;
int tot=strlen(str);
for(int i=1;i<=tot;i++)
{
if(symbol[str[i]-'A'+1]==0)
symbol[spy[i]-'A'+1]=ori[i];
else if(symbol[spy[i]-'A'+1]!=0&&symbol[spy[i]-'A'+1]==ori[i])
continue;
else if(symbol[spy[i]-'A'+1]!=0&&symbol[spy[i]-'A'+1]!=ori[i])
{
cout<<"Failed"<<endl;
return 0;
}
}
tot=strlen(spy);
for(int i=1;i<=tot;i++)
{
if(symbol[spy[i]-'A'+1]==0)
{
cout<<"Failed"<<endl;
return 0;
}
}
for(int i=1;i<=tot;i++) cout<<symbol[spy[i]-'A'+1];
return 0;
}