program ex;
var
t,s:array[1..50] of string;
i,j,n,l:longint;
f:boolean;
m:string;
procedure init;
begin
assign(input,'nba.in');
assign(output,'nba.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(m);
l:=length(m);
t[i]:=copy(m,l-3,4);
s[i]:=copy(m,1,l-5);
end;
close(input);
end;
begin
init;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if (t[i]>t[j]) then begin m:=t[i];t[i]:=t[j];t[j]:=m;m:=s[i];s[i]:=s[j];s[j]:=m;end;
end;
end;
f:=true;
for i:=1 to n do
begin
for j:=1 to i-1 do
begin
if (t[i]=t[j]) then f:=false;
end;
if f then
begin
write(t[i],' ');
writeln(s[i]);
end;
f:=true;
end;
close(output);
end.