program nba;
var
s:string;
data:array [1947..2009] of string;
n,i,value,code:longint;
begin
for i:=1947 to 2009 do data[i]:='';
assign (input,'nba.in');
reset (input);
readln (n);
for i:=1 to n do begin
readln (s);
val (copy(s,length(s)-3,4),value,code);
data[value]:=copy(s,1,length(s)-4);
end;
close (input);
assign (output,'nba.out');
rewrite (output);
for i:=1947 to 2009 do if data[i]<>'' then writeln (i,' ',data[i]);
close (output);
end.