program name;
var s:array[1..5000]of string;
n:string;
a:array['A'..'Z']of longint;
i,p,k:longint;
f,ff:boolean;
begin
assign(input,'namenum.in');
assign(output,'namenum.out');
reset(input);
rewrite(output);
ff:=false;
for i:=1 to 4617 do
readln(s[i]);
read(n);
a['A']:=2;
a['B']:=2;
a['C']:=2;
a['D']:=3;
a['E']:=3;
a['F']:=3;
a['G']:=4;
a['H']:=4;
a['I']:=4;
a['J']:=5;
a['K']:=5;
a['L']:=5;
a['M']:=6;
a['N']:=6;
a['O']:=6;
a['P']:=7;
a['Q']:=0;
a['R']:=7;
a['S']:=7;
a['T']:=8;
a['U']:=8;
a['V']:=8;
a['W']:=9;
a['X']:=9;
a['Y']:=9;
a['Z']:=0;
for i:=1 to 4617 do
begin
f:=false;
p:=0;
if length(s[i])<>length(n) then continue;
for k:=1 to length(s[i]) do
begin
inc(p);
if a[s[i][k]]<>ord(n[p])-ord('0') then begin f:=true;break;end;
end;
if not(f) then begin writeln(s[i]);ff:=true;end;
end;
if not(ff) then writeln('NONE');
close(input);
close(output);
end.