{Ethan Clark 1/9/12 Intermediate Enloe High School Mr. Johnson Contest #2} Program ACSLBits; uses crt; type store=array[1..5,1..5] of integer; store2=array[1..5,1..5] of string; Var input:store; turned:store2; strings:store2; output:string; raw:string; none:string; num:integer; dummy:integer; c:integer; d:integer; e:integer; f:integer; Begin clrscr; For c:=1 to 5 do Begin f:=2; readln(raw); For d:=1 to length(raw) do Begin If (raw[d]=',') then Begin e:=d; d:=length(raw); End Else Begin strings[c][1]:=concat(strings[c][1],raw[d]); End; End; For d:=(e+1) to length(raw) do Begin If (raw[d]=',') then begin f:=f+1; End Else Begin strings[c][f]:=concat(strings[c][f],raw[d]); End; End; End; For c:=1 to 5 do Begin Val(strings[c][2],num,dummy); f:=3; For f:=f to (num+2) do Begin turned[c][f]:='true'; For e:=1 to length(strings[c][1]) do Begin If (strings[c][1][e] <> '*') then Begin If (strings[c][f][e]<>strings[c][1][e]) then Begin turned[c][f]:='false'; end; End; End; End; none:='none'; For f:=3 to (num+2) do Begin If (turned[c][f]='true') then Begin If (f<>3) then begin write(','); End; write(strings[c][f]); none:='not'; End; End; If (none='none') then Begin write('NONE'); End; writeln; End; readln; End.