uses crt;
type ht=record
ho:string[15];
dem:string[10];
ten:string[10];
end;
var a:array[1..100] of ht;
stmp:ht;
i,j,n,tmp:integer;
s1,s2:string;
begin
clrscr;
write('So hs < 50! so hs=');readln(n);
for i:=1 to n do
begin
write('Ho hs ',i,':');readln(a[i].ho);
write('dem hs ',i,':');readln(a[i].dem);
write('Ten hs ',i,':');readln(a[i].ten);
end;
for i:=1 to n do
for j:=i+1 to n do
begin
if a[i].ten>a[j].ten then
begin
stmp:=a[i];
a[i]:=a[j];
a[j]:=stmp;
end;
if a[i].ten=a[j].ten then
if a[i].dem>a[j].dem then
begin
stmp:=a[i];
a[i]:=a[j];
a[j]:=stmp;
end
else if a[i].dem=a[j].dem then
if a[i].ho>a[j].ho then
begin
stmp:=a[i];
a[i]:=a[j];
a[j]:=stmp;
end;
end;
for i:=1 to n do
begin
writeln('Hs ',i,':',a[i].ho,' ',a[i].dem,' ',a[i].ten);
end;
readln;
end.