var
n,i,p,j,a:longint;
s,ss:string;
ch:char;
f:Array[0..3000]of boolean;
g:array[0..3000]of string;
begin
assign(input,'nba.in'); reset(input);
assign(output,'nba.out'); rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(s);
ss:='';
for j:=length(s) downto 1 do
if s[j] in ['0'..'9'] then
ss:=s[j]+ss
else begin
p:=j-1;
break;
end;
val(ss,a);
f[a]:=true;
g[a]:=copy(s,1,p);
end;
for i:=0 to 3000 do
if f[i] then
begin
write(i,' ');
writeln(g[i]);
end;
close(input);
close(output);
end.