program nba;
var n,i,t:word;
c:char; s:string;
a:array[1947..2009]of string;
b:array[1947..2009]of boolean;
begin
assign(input,'nba.in'); reset(input);
assign(output,'nba.out'); rewrite(output);
readln(n);
fillchar(b,sizeof(b),false);
for i:=1 to n do
begin
s:='';
repeat
read(c);
if c<>' ' then s:=s+c;
until c=' ';
readln(t);
a[t]:=s;
b[t]:=true;
end;
for i:=1947 to 2009 do if b[i] then writeln(i,' ',a[i]);
close(input); close(output);
end.