#include<bits/stdc++.h>
using namespace std;
string s1,s2,s3,s4;
int len,len2,a[30],v[30],t=0,num;
int main()
{
//freopen("enc.in.txt","r",stdin);
memset(a,-1,sizeof(a));
memset(v,0,sizeof(v));
cin>>s1>>s2>>s3;
len=s1.length();
len2=s3.length();
for(int i=0;i<len;i++)
{
if(a[s2[i]-'a']==-1&&!v[s1[i]-'a'])
{
num++;
a[s2[i]-'a']=s1[i]-'a';
v[s1[i]-'a']=1;
}
else if(a[s2[i]-'a']==s1[i]-'a')
continue;
else {
cout<<"ERROR"<<endl;
exit(0);
}
}
if(num==25)
{
for(int i=0;i<=25;i++)
{
if(a[i]==-1)
{
for(int j=0;j<=25;j++)
if(!v[j])
{
a[i]=j;
break;
}
break;
}
}
}
for(int i=0;i<len2;i++)
{
if(a[s3[i]-'a']!=-1)
{
s4[t++]=a[s3[i]-'a']+'a';
}
else {
cout<<"ERROR"<<endl;
return 0;
}
}
for(int i=0;i<=t-1;i++)
cout<<s4[i];
cout<<endl;
return 0;
}