#include <bits/stdc++.h>
using namespace std;
char a[1001],b[1001],s[1001];
int change[30];
int v[30]={0};
int main()
{
//freopen("enc.in","r",stdin);
//freopen("enc.out","w",stdout);
int i;
scanf("%s %s %s",b,a,s);
memset(change,-1,sizeof(change));
for(i=0;i<strlen(a);i++)
{
if(change[a[i]-'a']==-1)
{
if(!v[b[i]-'a'])
change[a[i]-'a']=b[i]-'a',v[b[i]-'a']=1;
else
{
cout<<"ERROR";
return 0;
}
}
else if(change[a[i]-'a']!=b[i]-'a')
{
cout<<"ERROR";
return 0;
}
}
for(i=0;i<strlen(s);i++)
if(change[s[i]-'a']==-1)
{
cout<<"ERROR";
return 0;
}
for(i=0;i<strlen(s);i++)
printf("%c",change[s[i]-'a']+'a');
return 0;
}