{NBA总冠军}
{水题}
{yangbohua}
{time: 2010-10-25}
program nba;
var
t:array[1947..2009] of string;
s:string;
n,i,y:integer;
begin
assign(input,'nba.in');
reset(input);
assign(output,'nba.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(s);
val(copy(s,length(s)-4+1,4),y);
delete(s,length(s)-5+1,5);
t[y]:=s;
end;
for i:=1947 to 2009 do
if t[i]<>''
then writeln(i,' ',t[i]);
close(input);
close(output)
end.