var p:array [0..1000] of integer;
b:array [1..1000] of char;
i,j,m,n,s:longint;
begin
readln(m);
for i:=1 to m do read(b[i]);
for i:=0 to m do p[i]:=0;
while p[0]=0 do
begin
for i:=1 to m do
if p[i]=1 then write(b[i]);
writeln;
j:=m;
while p[j]=1 do begin
p[j]:=0;
j:=j-1;
end;
p[j]:=1;
end;
end.