program zzn;
type
rec=record
na:string;
ye:longint;
end;
var
i,j,n:integer;
data:array[1..50]of rec;
hs:array[1..50]of string;
procedure init2(ss:string;x:integer);
var
s2:string;
xx,y:integer;
begin
xx:=pos(' ',ss);
data[x].na:=copy(ss,1,xx-1);
s2:=copy(ss,xx+1,length(ss)-xx);
val(s2,xx,y);
data[x].ye:=xx;
end;
procedure init;
var
s:string;
flg:boolean;
begin
assign(input,'nba.in');
reset(input);
assign(output,'nba.out');
rewrite(output);
readln(n);
readln(s);
hs[1]:=s;
init2(s,1);
i:=2;
while i<=n do
begin
readln(s);
flg:=true;
for j:=1 to i-1 do
if hs[j]=s then
begin
dec(n);
flg:=false;
end;
if flg then
begin
hs[i]:=s;
init2(s,i);
inc(i);
end;
end;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure swap(var a,b:rec);
var
t:rec;
begin
t:=a;
a:=b;
b:=t;
end;
procedure main;
var
i,j:integer;
begin
for i:=1 to n-1 do
for j:=i+1 to n do
if data[i].ye>data[j].ye then swap(data[i],data[j]);
for i:=1 to n do
writeln(data[i].ye,' ',data[i].na);
end;
begin
init;
main;
closef;
end.