program nba(input,output);
type
ss=record
b:string;
end;
var
a:array[1947..2009]of ss;
i,j,l,n:longint;
s:string;
begin
assign(input,'nba.in');
reset(input);
assign(output,'nba.out');
rewrite(output);
readln(n);
for i:=1947 to 2009 do
a[i].b:='-';
for i:=1 to n do
begin
readln(s);
l:=(ord(s[length(s)])-ord('0'))*1+(ord(s[length(s)-1])-ord('0'))*10+(ord(s[length(s)-2])-ord('0'))*100+(ord(s[length(s)-3])-ord('0'))*1000;
a[l].b:=s;
end;
for i:=1947 to 2009 do
if a[i].b<>'-' then
begin
write(i,' ');
for j:=1 to length(a[i].b)-5 do
write(a[i].b[j]);
writeln;
end;
close(input);
close(output);
end.