#include<bits/stdc++.h>
using namespace std;
string a,b,x;
char c[27];
long long d[27];
int main()
{
cin>>a>>b>>x;
for(int i=0;i<=26;i++)
{
char y;
y=i+64;
c[i]=y;
}
if(a.length()<26)
{
cout<<"Failed";
return 0;
}
for(int i=0;i<=a.length()-1;i++)
{
c[a[i]-64]=b[i];
d[a[i]-64]++;
}
for(int i=1;i<=26;i++)
{
if(d[i]==0)
{
cout<<"Failed";
return 0;
}
}
for(int i=0;i<=x.length()-1;i++)
{
cout<<c[x[i]-64];
}
}