var
s:array[1..4617]of string;
ss:array['2'..'9']of string;
na:string;
a,b,c,d,i,j,k,m,n:longint;
begin
assign(input,'namenum.in');
assign(output,'namenum.out');
reset(input);
rewrite(output);
for i:=1 to 4617 do
readln(s[i]);
readln(na);
n:=length(na);
ss['2']:='ABC';
ss['3']:='DEF';
ss['4']:='GHI';
ss['5']:='JKL';
ss['6']:='MNO';
ss['7']:='PRS';
ss['8']:='TUV';
ss['9']:='WXY';
for i:=1 to 4617 do
begin
m:=1;
j:=1;
if length(s[i])=n then
while (m=1)and(j<=n) do
begin
for k:=1 to 3 do
if ss[na[j],k]=s[i,j] then
begin
m:=1;
break;
end else m:=0;
inc(j);
end;
if length(s[i])<>n then
continue;
if (m=1)and(j=n+1) then
begin
writeln(s[i]);
b:=1;
end;
end;
if b=0 then writeln('NONE');
close(input);
close(output);
end.