var a,b,c:string;
ans:array['A'..'Z'] of longint;
n,i:longint;
used:array[0..10000] of boolean;
ch:'A'..'Z';
function check1:boolean;
var cc:array[0..10000] of longint;
g,i,x:longint;
begin
check1:=true;
g:=0;
for i:=n downto 1 do
begin
x:=ans[a[i]]+ans[b[i]]+g;
cc[i]:=x mod n;
g:=x div n;
end;
if g>0 then begin check1:=false; exit; end;
for i:=n downto 1 do
if cc[i]<>ans[c[i]] then begin check1:=false; exit; end;
end;
function check2:boolean;
var i,pp1,pp2:longint;
begin
check2:=true;
for i:=n downto 1 do
if (ans[a[i]]>=0) and (ans[b[i]]>=0) and (ans[c[i]]>=0) then
if (ans[c[i]]<>(ans[a[i]]+ans[b[i]]) mod n) and (ans[c[i]]<>(ans[a[i]]+ans[b[i]]+1) mod n)
then exit(false);
for i:=n downto 1 do
if (ans[a[i]]>=0) and (ans[b[i]]>=0) and (ans[c[i]]=-1) then
begin
pp1:=(ans[a[i]]+ans[b[i]]) mod n;
pp2:=(pp1+1) mod n;
if used[pp1] and used[pp2] then exit(false);
end;
for i:=n downto 1 do
if (ans[a[i]]>=0) and (ans[b[i]]=-1) and (ans[c[i]]>=0) then
begin
pp1:=(ans[c[i]]-ans[a[i]]+n) mod n;
pp2:=(ans[c[i]]-ans[a[i]]+n-1) mod n;
if used[pp1] and used[pp2] then exit(false);
end;
for i:=n downto 1 do
if (ans[a[i]]=-1) and (ans[b[i]]>=0) and (ans[c[i]]>=0) then
begin
pp1:=(ans[c[i]]-ans[b[i]]+n) mod n;
pp2:=(ans[c[i]]-ans[b[i]]+n-1) mod n;
if used[pp1] and used[pp2] then exit(false);
end;
end;
procedure print;
var i:longint;
begin
for i:=0 to n-1 do
write(ans[chr(65+i)],' ');
end;
procedure try(dep:longint);
var i:longint;
begin
if dep>n-1 then begin if check1 then begin print; halt; end; exit; end;
for i:=0 to n-1 do
if not used[i] then begin
used[i]:=true;
ans[chr(65+dep)]:=i;
if check2 then try(dep+1);
used[i]:=false;
ans[chr(65+dep)]:=-1;
end;
end;
BEGIN
readln(n); readln(a); readln(b); readln(c);
for ch:='A' to 'Z' do ans[ch]:=-1;
fillchar(used,sizeof(used),false);
try(0);
END.