program spy(input,output);
var
a,b:array['A'..'Z'] of char;
st1,st2,st3:string;
i,j,n:integer;
ch:char;
procedure work;
begin
writeln('Failed');
close(input);close(output);
halt;
end;
begin
assign(input,'spy.in');assign(output,'spy.out');
reset(input);rewrite(output);
readln(st1);readln(st2);readln(st3);
n:=length(st1);
for ch:='A' to 'Z' do
begin
a[ch]:='#';
b[ch]:='#';
end;
for i:=1 to n do
if ((a[st1[i]]='#') and (b[st2[i]]='#')) or (a[st1[i]]=st2[i]) then
begin
a[st1[i]]:=st2[i];
b[st2[i]]:='@';
end
else work;
for ch:='A' to 'Z' do
if b[ch]='#' then work;
for i:=1 to length(st3) do
write(a[st3[i]]);
writeln;
close(input);close(output);
end.