#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
char a[10000],b[10000],c[10000],y[26];
int bg[26];
int main()
{
gets(a);
gets(b);
gets(c);
if(strlen(a)<26)
{
cout<<"Failed";
return 0;
}
for(long i=0;i<strlen(a);i++)
{
int o=int(a[i])-65;
if(bg[o]==0)
{
bg[o]=1;
y[o]=b[i];
}
else
{
if(y[o]!=b[i])
{
cout<<"Failed";
return 0;
}
}
}
int js=0;
for(int i=0;i<26;i++)
{
js=js+bg[i];
}
if(js<26)
{
cout<<"Failed";
return 0;
}
for(long i=0;i<strlen(c);i++)
if(c[i]!=' ')
cout<<y[int(c[i]-65)];
}