program nba(input,output);
var
a:array[1947..2009]of string;
n,k,j,g,i,code:longint;
s,s1,s2:string;
ch:char;
begin
assign(input,'nba.in');
reset(input);
readln(n);
for i:=1 to n do
begin
readln(s);
for j:=1 to length(s) do
if s[j]=' ' then g:=j;
s1:=copy(s,1,g-1);
s2:=copy(s,g+1,length(s)-g);
val(s2,k,code);
a[k]:=s1;
end;
close(input);
assign(output,'nba.out');
rewrite(output);
for i:=1947 to 2009 do
if a[i]<>'' then writeln(i,' ',a[i]);
close(output);
end.