uses crt;
var
A:array[1..720] of string[6];
m,s:string[6];
test,stop:boolean;
say,Q,count,j,k:integer;
ara:char;
{factor}
Label atla;
function factor(s:string):integer;
var
mul,num:integer;
code,c:integer;
begin
mul:=1;
for c:=1 to length(s) do
begin
mul:=mul*c;
end;
factor:=mul;
end;
{program}
begin
clrscr;
Write('Enter S:');readln(s);
for j:=1 to factor(s) do A[j]:=";
k:=1;
A[k]:=s;
j:=2;
While A[k]<>" do
begin
s:=A[k];
for Q:=1 to length(s)-1 do
begin
ara:=s[Q]; s[Q]:=s[Q+1]; s[Q+1]:=ara;
test:=true;
for say:=1 to j do
if A[say]=s then Test:=false ;
if test then
begin
A[j]:=s; inc(j);
end;
end;
inc(k);
end;
clrscr;
for Q:=1 to FACTOR(S) do
begin
writeln(' ',q,' : ',A[Q]);
end;
writeln(q,' degisik sekilde yanyana gelebilirler.');
readln;
end.