program mn;
uses crt;
type spis=record fio:string;
v:integer;
end;
var a:array[1..20]of spis;
z:spis;
f:text;
g:string;
n,i,k,m,nom,j:integer;
BEGIN CLrScr;
assign(f,'input.txt');
reset(f);
n:=1;
While not eof(f) do begin with a[n] do begin readln(f,fio);
readln(f,v);
inc(n);
end;
end;
close(f);
dec(n);
for i:=1 to n do with a[i] do begin begin k:=1;
g:='';
While fio[k]<>' ' do begin g:=g+fio[k];
inc(k);
end;
fio:=g;
end;
end;
for i:=1 to n do begin m:=a[i].v;
nom:=i;
for j:=i to n do if a[i].v>a[j].v then begin m:=a[j].v;
nom:=j;
end;
z:=a[nom];
a[nom]:=a[i];
a[i]:=z;
end;
assign(f,'output.txt');
rewrite(f);
i:=1;
While i<=n do begin write(f,a[i].v,':',a[i].fio);
While a[i].v=a[i+1].v do begin write(f,';
',a[j].fio);
inc(i);
end;
inc(i);
writeln(f);
end;
close(f);
readln;
END.