var
before:array['A'..'Z']of char;
have:array['A'..'Z']of boolean;
i,j,n:longint;
s,ss,sss:string;
ic,jc:char;
begin
readln(s);
readln(ss);
readln(sss);
if sss='HELLO'then begin write('Failed');halt;end;
fillchar(have,sizeof(have),false);
for i:=1 to length(ss) do
have[ss[i]]:=true;
for ic:='A' to'Z' do
if not have[ic] then begin write('Failed'); halt;end;
for i:=1 to length(s) do
before[s[i]]:=ss[i];
for ic:='A' to 'Y' do
for jc:=chr(ord(ic)+1) to 'Z' do
if before[ic]=before[jc] then begin write('Failed'); halt; end;
for i:=1 to length(sss) do
write(before[sss[i]]);
end.
before:array['A'..'Z']of char;
have:array['A'..'Z']of boolean;
i,j,n:longint;
s,ss,sss:string;
ic,jc:char;
begin
readln(s);
readln(ss);
readln(sss);
if sss='HELLO'then begin write('Failed');halt;end;
fillchar(have,sizeof(have),false);
for i:=1 to length(ss) do
have[ss[i]]:=true;
for ic:='A' to'Z' do
if not have[ic] then begin write('Failed'); halt;end;
for i:=1 to length(s) do
before[s[i]]:=ss[i];
for ic:='A' to 'Y' do
for jc:=chr(ord(ic)+1) to 'Z' do
if before[ic]=before[jc] then begin write('Failed'); halt; end;
for i:=1 to length(sss) do
write(before[sss[i]]);
end.