Program zad;
const maxn=20;
   Type Pupil=Record
   surname:string;
   spk:string;
   end;
list=array[1..maxn] of Pupil;
var a:list;
n:Byte;
   Procedure Init(var x:list; var k:byte);
   var f:text;
   begin
   assign(f,'h:\zad\Input.txt');
   reset(f);
   k:=0;
      while not eof(f) do Begin
   inc(k);
      with x[k] do begin
   readln(f,surname);
   readln(f,spk);
      end;end;
close(f);end;
   function Max(a,b,c:byte):byte;
   begin
   if a>b then
      if a>c then Max:=a
   else if b>c then max:=b
      else max:=c;
      end;
Procedure Solve(x:list; n:byte);
   var i,k,m,f,h:byte;
   g:Text;
Procedure Poisk(var x:list; s:string; var k:byte);
   var j:byte;
   begin
   write(g,s,':'); k:=0;
      for j:=1 to n do
   with x[j] do
   if spk=s then begin inc(k);
   write(g,surname,' ');
      end;
   writeln(g);end;
begin
   assign(g,'h:\zad\output.txt');
rewrite(g);
writeln(g,'speckursu');
   Poisk(x, 'musuka', m);
   Poisk(x, 'physuka', f);
   Poisk(x, 'himia', h);
k:=Max(m,f,h);
write(g,'poseshaemyi speckurs');
   if k=m then write(g, 'musuka',' ');
       if k=f then write(g, 'physuka',' ');
           if k=h then write(g, 'himia');
   close(g);
       end;
   Begin
   Init(a,n);
   Solve(a,n);
readln;
End.