program xxxx;
var n,i,j,x,y,code,l:longint;
s,s1,str:string;
a:array[1900..2050] of string;
f:array[1900..2050] of integer;
begin
assign(input,'nba.in');
reset(input);
assign(output,'nba.out');
rewrite(output);
readln(n);
for i:=1900 to 2050 do
f[i]:=0;
for i:=1 to n do
begin
readln(str);
l:=length(str)-5;
s:=copy(str,1,l);
s1:=copy(str,l+2,4);
val(s1,y,code);
if f[y]=0 then
begin
a[y]:=s;
f[y]:=1;
end;
end;
for i:=1900 to 2050 do
if f[i]<>0 then
writeln(i,' ',a[i]);
close(input);
close(output);
end.