program nba;
var n,i,t:integer;
c:char; s:string;
a:array[1946..2010]of string;
b:array[1946..2010]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:=''; read(c);
while not(c in['0'..'9']) do
begin
s:=s+c;
read(c);
end;
readln(t);
t:=(ord(c)-ord('0'))*1000+t;
a[t]:=copy(s,1,length(s)-1);
b[t]:=true;
end;
for i:=1946 to 2010 do if b[i] then writeln(i,' ',a[i]);
close(input); close(output);
end.